EasyDeepLearn

When does log-transforming the target help a regression model?

medium

Answer

  • 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 log(y)\operatorname{log}(y) is equivalent to modeling percentage errors.
  • Watch out: predictions in log space need exp()\operatorname{exp}() to be brought back, and the expectation is biased (E[exp(z)]    exp(E[z]))(E[\operatorname{exp}(z)]\; \ne \;\operatorname{exp}(E[z])).
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