Package org.apache.spark.mllib.recommendation

Examples of org.apache.spark.mllib.recommendation.Rating


    public Rating call(String line) {
      String[] tok = COMMA.split(line);
      int x = Integer.parseInt(tok[0]);
      int y = Integer.parseInt(tok[1]);
      double rating = Double.parseDouble(tok[2]);
      return new Rating(x, y, rating);
    }
View Full Code Here


  private static JavaRDD<Rating> parsedToRatingRDD(JavaRDD<String[]> parsedRDD) {
    return parsedRDD.map(new Function<String[],Rating>() {
      @Override
      public Rating call(String[] tokens) {
        int numTokens = tokens.length;
        return new Rating(
            Integer.parseInt(tokens[0]),
            Integer.parseInt(tokens[1]),
            numTokens == 3 ? Double.parseDouble(tokens[2]) : 1.0);
      }
    });
View Full Code Here

  private static final class TupleToRatingFn
      implements Function<Tuple2<Tuple2<Integer,Integer>,Double>,Rating> {
    @Override
    public Rating call(Tuple2<Tuple2<Integer,Integer>,Double> userProductScore) {
      Tuple2<Integer,Integer> userProduct = userProductScore._1();
      return new Rating(userProduct._1(), userProduct._2(), userProductScore._2());
    }
View Full Code Here

    public Rating call(String line) {
      String[] tok = COMMA.split(line);
      int x = Integer.parseInt(tok[0]);
      int y = Integer.parseInt(tok[1]);
      double rating = Double.parseDouble(tok[2]);
      return new Rating(x, y, rating);
    }
View Full Code Here

public final class RatingToTupleDoubleTest extends OryxTest {

  @Test
  public void testFunction() {
    Tuple2<Tuple2<Integer,Integer>,Double> tuple =
        new RatingToTupleDouble().call(new Rating(1, 2, 3.0));
    assertEquals(1, tuple._1()._1().intValue());
    assertEquals(2, tuple._1()._2().intValue());
    assertEquals(3.0, tuple._2().doubleValue());
  }
View Full Code Here

TOP

Related Classes of org.apache.spark.mllib.recommendation.Rating

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.