liveBook · Manning

Log transformation

As explained in Ensemble Methods for Machine Learning

A log transformation maps a nonnegative value y to log(1+y), avoiding the undefined logarithm of zero while compressing large values.

A log transformation changes each nonnegative count y to log(1 + y). Adding 1 keeps zero counts defined while reshaping a right-skewed distribution. section 7.4.1

For the Bike Sharing data, casual-user counts range from 0 to 367 and contain many zeros with a long right tail. Comparing histograms before and after transformation helps reveal suitable modeling assumptions. section 7.4.1

The transformed target suggests two modeling directions:

  • Use a Tweedie distribution when zeros and right-skewed positive values resemble a compound Poisson-gamma pattern. section 7.4.1
  • Use a log-link function in a generalized linear model, or extend that intuition through supported ensemble methods. section 7.4.1

Bike Sharing counts

Inspect the casual-user histogram, transform every target with log(1 + y), and compare the resulting shape before selecting a distribution or link function. section 7.4.1

Figure 7.13 Histogram of count-valued targets, the number of casual users (left); histogram of the count targets after log transformation (right)
CH07_F13_Kunapuli

Compare the original count histogram with the histogram after log transformation. section 7.4.1

How Ensemble Methods for Machine Learning covers it

How deep it goes
Defines the transformation and its purpose, then stops at distributional interpretation rather than implementation details.
Examples
Uses casual-user counts from the Bike Sharing data and compares their original and transformed histograms.
What you can do after
Evaluate count-label distributions and select plausible Tweedie or log-link modeling assumptions.
How it connects
Connects count-valued targets with Tweedie distributions, generalized linear models, log-link functions, Poisson distributions, and gamma distributions.

Also explained in

Compare how 2 books explain log transformation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Ensemble Methods for Machine Learning. The section links point to the parts of the book it draws on.