Bitzu

Machine Learning Associate ยท Exploring and preparing data

Log scale transformation

Scenarios where a log transformation is appropriate (right-skewed, multiplicative spread, positive values only) and its limits.

Key points

  • Strictly positive, right-skewed data spanning orders of magnitude (prices, incomes, counts): log pulls in the long tail, turns multiplicative effects additive.
  • Zeros need log1p, i.e. log(1 + x); negatives cannot be logged.
  • No help for left-skewed data; mostly unnecessary for tree models (order is kept).
  • Logged target: exponentiate predictions (exp, or expm1 for log1p) before metrics or reporting in original units.

Practice questions

Single choice

Which values make a plain natural-log transform invalid?

  1. Zero and negative values
  2. Values larger than 1000
  3. Values with decimals
  4. Values that repeat
Show answer

Answer: A. Zero and negative values

The logarithm is defined only for positive numbers; zero and negatives need a different treatment such as log1p (for zeros) or another transform.

Select all that apply

Which scenarios fit a log transformation?

  1. A strictly positive, right-skewed income column
  2. Web response sizes ranging from bytes to gigabytes
  3. A non-negative count column with many zeros, using log1p
  4. A left-skewed score column capped at 100
  5. Profit and loss values that are often negative
Show answer

Answer: A. A strictly positive, right-skewed income column, B. Web response sizes ranging from bytes to gigabytes, C. A non-negative count column with many zeros, using log1p

Positive right-skewed data and values spanning orders of magnitude fit; zeros need log1p. Left-skewed data would get worse, and negative values cannot be logged.

True or false

True or false: log-transforming a feature changes the order of its values, so a decision tree will find different splits.

Show answer

Answer: False

False. Log is monotonic, so the order of values is unchanged and a tree can make equivalent splits. Log helps mainly linear and distance-based models.

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.

Download on the App StoreGet it on Google Play

More Machine Learning Associate topics in this module