QuestionQ77

VerifiedModel Development

A data scientist created a linear regression model that uses log(price) as its label variable. After running inference, the predictions and actual label values are in the Spark DataFrame preds_df.

They evaluate the model using the following code block:

regression_evaluator.setMetricName("rmse").evaluate(preds_df)  

Which change should the data scientist make to evaluate RMSE so that it is comparable with price?

Explanation

RMSE is expressed in the same scale as the evaluator’s prediction and label columns. A model trained on log(price) therefore produces an RMSE in log-price units; applying exp to the final RMSE does not convert it into a price-unit RMSE. The predictions must be inverse-transformed to price before calculating the error, and the actual values used by the evaluator must likewise be in price units. Spark’s RegressionEvaluator computes RMSE from its prediction and label columns.

Learn more

Community Discussion

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