app/oryx-app-mllib/src/main/java/com/cloudera/oryx/app/batch/mllib/als/Evaluation.java
static double rmse(MatrixFactorizationModel mfModel, JavaRDD<Rating> testData) {
    JavaPairRDD<Tuple2<Integer,Integer>,Double> testUserProductValues =
        testData.mapToPair(rating -> new Tuple2<>(new Tuple2<>(rating.user(), rating.product()), rating.rating()));
    @SuppressWarnings("unchecked")
    RDD<Tuple2<Object,Object>> testUserProducts =
        (RDD<Tuple2<Object,Object>>) (RDD<?>) testUserProductValues.keys().rdd();
    JavaRDD<Rating> predictions = testData.wrapRDD(mfModel.predict(testUserProducts));
    double mse = predictions.mapToPair(
        rating -> new Tuple2<>(new Tuple2<>(rating.user(), rating.product()), rating.rating())
    ).join(testUserProductValues).values().mapToDouble(valuePrediction -> {
      double diff = valuePrediction._1() - valuePrediction._2();
      return diff * diff;
    }).mean();
    return Math.sqrt(mse);
  }
static double rmse(MatrixFactorizationModel mfModel, JavaRDD<Rating> testData) {
    JavaPairRDD<Tuple2<Integer,Integer>,Double> testUserProductValues =
        testData.mapToPair(rating -> new Tuple2<>(new Tuple2<>(rating.user(), rating.product()), rating.rating()));
    @SuppressWarnings("unchecked")
    RDD<Tuple2<Object,Object>> testUserProducts =
        (RDD<Tuple2<Object,Object>>) (RDD<?>) testUserProductValues.keys().rdd();
    JavaRDD<Rating> predictions = testData.wrapRDD(mfModel.predict(testUserProducts));
    double mse = predictions.mapToPair(
        rating -> new Tuple2<>(new Tuple2<>(rating.user(), rating.product()), rating.rating())
    ).join(testUserProductValues).values().mapToDouble(valuePrediction -> {
      double diff = valuePrediction._1() - valuePrediction._2();
      return diff * diff;
    }).mean();
    return Math.sqrt(mse);
  }
Computes root mean squared error of {@link Rating#rating()} versus predicted value.