QuestionQ126

VerifiedValidation 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?

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!