Multiple Evaluators in CrossValidator - Spark ML

Viewed 76

Is it possible to have more than 1 evaluator in a CrossValidator to get R2 and RMSE at the same time?

Instead of having two different CrossValidator:

    val lr_evaluator_rmse = new RegressionEvaluator()
                           .setLabelCol("ArrDelay")
                           .setPredictionCol("predictionLR")
                           .setMetricName("rmse")
    
    val lr_evaluator_r2 = new RegressionEvaluator()
                         .setLabelCol("ArrDelay")
                         .setPredictionCol("predictionLR")
                         .setMetricName("r2")
    
    val lr_cv_rmse = new CrossValidator()
                      .setEstimator(lr_pipeline)
                      .setEvaluator(lr_evaluator_rmse)
                      .setEstimatorParamMaps(lr_paramGrid)
                      .setNumFolds(3)
                      .setParallelism(3)
    
    val lr_cv_r2 = new CrossValidator()
                  .setEstimator(lr_pipeline)
                  .setEvaluator(lr_evaluator_rmse)
                  .setEstimatorParamMaps(lr_paramGrid)
                  .setNumFolds(3)
                  .setParallelism(3)

Something like this:

val lr_cv = new CrossValidator()
        .setEstimator(lr_pipeline)
        .setEvaluator(lr_evaluator_rmse)
        .setEvaluator(lr_evaluator_r2)
        .setEstimatorParamMaps(lr_paramGrid)
        .setNumFolds(3)
        .setParallelism(3)

Thanks in advance

0 Answers
Related