Machine Learning Associate ยท Model evaluation and generalization
Exponentiate predictions from a log-target model before reporting metrics
Exponentiating predictions from a model trained on a log-transformed target before computing metrics or interpreting results in original units.
Key points
- If you train on log(y), the model outputs log-scale values.
- Metrics computed on them are in log units and measure roughly relative error.
- To report error in the original units, apply the inverse transform to the predictions (np.exp for np.log, np.expm1 for np.log1p) and compare with the original y. Never compare a log-scale RMSE directly with a raw-scale RMSE of another model.
Practice questions
A model was trained on np.log(price). Which operation converts its predictions back to price units?
- np.log
- np.sqrt
- np.square
- np.exp
Show answer
Answer: D. np.exp
The inverse of the natural logarithm is the exponential, np.exp. Applying np.log again or taking a square root does not undo it.
Which statements about a model trained on a log-transformed target are correct?
- An RMSE computed on log-scale values is in log units, not original units
- np.expm1 is the inverse of np.log1p
- A log-scale RMSE should not be compared directly with a raw-scale RMSE of another model
- Exponentiating is only needed for classification models
- R-squared is guaranteed to be identical on both scales
Show answer
Answer: A. An RMSE computed on log-scale values is in log units, not original units, B. np.expm1 is the inverse of np.log1p, C. A log-scale RMSE should not be compared directly with a raw-scale RMSE of another model
Log-scale metrics are in log units, np.expm1 inverts np.log1p, and a log-scale RMSE cannot be compared with a raw-scale one. Back-transforming is needed for regression whatever the algorithm, and R-squared is not preserved across scales.
True or false: an RMSE of 0.2 on a log-transformed target means predictions are off by about 0.2 units of the original currency.
Show answer
Answer: False
False. The 0.2 is in log units, which corresponds roughly to a relative error of about 20%, not a fixed amount of currency.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
