Skip to content
ML Academy

Feature engineering and preprocessing · insight-0122

Log-transform skewed inputs for linear and distance models, not for trees

Evidence type
practitioner heuristic
Difficulty
easy
Roles
Data scientist, Data analyst
Industries
banking, retail

Summary: situation, action, reason, boundary

  1. Situation

    A numeric feature spans orders of magnitude, such as corporate account spend or group size.

  2. Action

    Apply a log (with an offset for zeros) or another monotone transform in the linear or distance branch, and leave the raw feature for tree models.

  3. Reason

    Many effects are multiplicative, so a log makes them closer to linear; trees are unaffected by monotone transforms anyway.

  4. Boundary

    Linear and logistic regression, k-NN, k-means and neural networks with heavy-tailed positive inputs.

Symptom or risk

Linear models fit the extreme rows and underfit the bulk; distance models treat a 10x difference as huge whatever the base.

Exceptions

Features with negative values or meaningful zeros need a different transform or a separate zero flag.

Trade-offs

Log scales help fit but make coefficients describe percentage changes, which you must explain.

Pitfalls

Choosing the offset after looking at test performance, or applying the transform differently in serving.

Lessons and concepts

Claims and their sources