Databricks Certified Machine Learning Associate · Free Practice Question Medium
Question 9
A Data scientist has created two regression models. The first model uses price as a label variable and the second model uses log(price) as a label variable.
When evaluating the RMSE of each model by comparing the label prediction to the actual price values, the data scientist notices that the RMSE for the second model is much longer than the RMSE of the first model.
Which of the following explanations for these differences is valid?
Choose only ONE best answer.
-
A
The second model is much more accurate than the first model.
-
B
The data scientist failed to take the log of the predictions in the first model prior to computing the RMSE.
-
C
The data scientist failed to exponentiate the predictions in the second model prior to computing the RMSE.
-
D
The RMSEis an invalid evaluation metric for regression problems.
-
E
The first model is much more accurate than the second model.
Reveal correct answer
Correct answer: C
Explanation
Correct Answer:
The data scientist failed to exponentiate the predictions in the second model prior to computing the RMSE.
Explanation:
When training a model on log-transformed labels (e.g., log(price)), the model's predictions will also be in log space. To compare these predictions to the original scale (e.g., actual price), you must reverse the transformation (exponentiate the predictions) before calculating RMSE.
Why This Matters:
Model 1: Predicts
pricedirectly → RMSE is calculated on the same scale.Model 2: Predicts
log(price)→ Predictions must be exponentiated (exp(pred)) to match thepricescale.If not exponentiated: RMSE compares
log(pred)toprice, which is invalid (apples-to-oranges).
Example:
- import numpy as np
- from sklearn.metrics import mean_squared_error
- # Actual prices
- actual_prices = np.array([100, 200, 300])
- # Model 1: Predicts price directly
- pred_prices = np.array([110, 190, 310])
- rmse1 = np.sqrt(mean_squared_error(actual_prices, pred_prices)) # Valid
- # Model 2: Predicts log(price)
- pred_log_prices = np.array([4.7, 5.2, 5.7])
- # Incorrect RMSE (log(pred) vs. actual price)
- rmse_incorrect = np.sqrt(mean_squared_error(actual_prices, pred_log_prices)) # Wrong!
- # Correct RMSE (exp(pred) vs. actual price)
- rmse_correct = np.sqrt(mean_squared_error(actual_prices, np.exp(pred_log_prices))) # Valid
Why Other Options Are Incorrect:
"The second model is much more accurate":
Invalid because the RMSE comparison is flawed (log vs. linear scale).
"Failed to take the log of predictions in the first model":
The first model predicts
pricedirectly; no log transformation is needed.
"RMSE is invalid for regression":
RMSE is a standard metric for regression, but scale consistency is critical.
"The first model is more accurate":
The comparison is invalid unless predictions are on the same scale.
Key Takeaway:
For models trained on log-transformed labels:
Exponentiate predictions (
exp(pred)) before calculating RMSE.Compare on the original scale (e.g.,
price).
Impact of Skipping Exponentiation:
RMSE will appear artificially high because
log(pred)values are much smaller thanprice.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
