// Evaluate model on training instances and compute training error
JavaPairRDD<Double, Double> regressorPredictionAndLabel =
data.mapToPair(new PairFunction<LabeledPoint, Double, Double>() {
@Override public Tuple2<Double, Double> call(LabeledPoint p) {
return new Tuple2<Double, Double>(regressionModel.predict(p.features()), p.label());
}
});
Double trainMSE =
regressorPredictionAndLabel.map(new Function<Tuple2<Double, Double>, Double>() {
@Override public Double call(Tuple2<Double, Double> pl) {