When does log-transforming the target help a regression model?
mediumAnswer
- Log-transform y when (1) y is strictly positive and right-skewed (revenue, counts, biological measurements, house prices), (2) residuals show heteroscedasticity that shrinks after the transform, (3) you care about relative rather than absolute errors — modeling is equivalent to modeling percentage errors.
- Watch out: predictions in log space need to be brought back, and the expectation is biased .
Check yourself — multiple choice
- Always log-transform the target
- When y is positive, right-skewed, or you care about relative errors
- Never for classification
- Log-transform improves accuracy for any model
Log helps with positive right-skewed targets and stabilizes variance.
#linear-regression#feature-engineering
Practise Supervised Learning
215 interview questions in this topic.
Related questions
- When should you add interaction features to a linear model?
- What do Box-Cox and Yeo-Johnson transforms do?
- Why does OLS have a closed-form solution but logistic regression doesn't?
- What are the classical assumptions of linear regression?
- How do you interpret a coefficient in a multiple linear regression?
- What is VIF and when do you worry about multicollinearity?