QuestionQ126

Validation Testing

A Machine Learning Engineer trained a linear regression model with SparkML to predict loan-default amounts. After producing predictions on the test dataset, the engineer wants to assess the model with multiple regression metrics at the same time. The predictions DataFrame contains the columns prediction, label, and features. The engineer must calculate both RMSE and R-squared (R2) values to provide stakeholders with comprehensive model-performance results.

Which approach accomplishes this?

  • A Create a RegressionEvaluator instance and set the parameter metricName to a list [‘rmse’, ‘r2’].
  • B Use a single RegressionEvaluator and call evaluate() twice with different parameter maps to override the metricName for each metric.
  • C Create a single RegressionEvaluator with metricName=“rmse” and use the model’s built-in summary statistics for R2.
  • D Use MulticlassClassificationEvaluator with metricName set to rmse and r2 respectively.
Explanation

Spark ML’s RegressionEvaluator supports rmse and r2 as individual metricName values. Each call to evaluate() returns one metric, and its optional parameter map can override the evaluator’s configured metricName; thus, calling it once for RMSE and once with metricName overridden to R2 produces both values.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!