I am trying to perform kfold validation in scala. I am using a random forest model and rmse as an evaluator. I can get the rmse values only for the best model.
Code:
val rf = new RandomForestRegressor().setLabelCol("label").setFeaturesCol("features").setNumTrees(2).setMaxDepth(2)
val paramGrid = new ParamGridBuilder().build()
val evaluator = new RegressionEvaluator().setMetricName("rmse").setLabelCol("label").setPredictionCol("prediction")
val cv = new CrossValidator().setEstimator(pipeline).setEvaluator(evaluator).setEstimatorParamMaps(paramGrid).setNumFolds(2).setParallelism(2)
val cvModel = cv.fit(trainingValDf)
I would like to print the individual rmse values in the validation phase.
Eg:
(1, 4.3)
(2, 4.4)
(3, 4.2)
.
.
.
(k, rmse for that iteration)
Please let me know how to do this in Scala. Thanks!