Reshaping Features with Binning, Log Transforms and Feature Splitting
This lesson explains three feature engineering techniques named in the exam guide, binning, log transformation and feature splitting, which make features more useful by changing their shape or breaking them into parts.
Learning outcomes
After completing this lesson, you will be able to:
- Apply a log transformation to skewed values.
- Distinguish fixed-width from quantile binning.
- Split compound values such as timestamps into features.
Log transformation
Values such as income, house prices, transaction amounts and counts are often right-skewed: most values are small and a few are very large. A log transformation (for example, log(1 + x) to handle zeros) compresses large values and makes the distribution closer to normal, which helps linear models and reduces the influence of extreme values. Predictions made on a log-transformed target must be transformed back with the inverse function.
The following diagram shows the transformation applied to each raw feature of a taxi tip prediction model.

Binning
Binning, also called bucketing or discretisation, groups continuous values into ranges. Fixed-width bins use equal ranges, such as ages 0 to 9, 10 to 19 and so on. Quantile bins put an equal number of records in each bin, which handles skewed data well, because a few extreme values do not leave most bins empty.
Binning helps in several ways. It lets linear models capture non-linear effects, such as risk that rises sharply above a certain age; it reduces the influence of noise and outliers; and it makes features easier to explain. The cost is lost detail, because all values within a bin are treated as the same.
Choose the transformation
Feature splitting
Feature splitting breaks a compound value into meaningful parts. A timestamp can become hour of day, day of week, month and an is-weekend flag, which expose daily and weekly patterns. An address can become city and postal code; a product code such as ELEC-TV-55 can become category, subcategory and size. Cyclical parts such as hour can be encoded with sine and cosine so that 23:00 and 00:00 are close.
The following table summarises the three techniques.
| Technique | Use when | Example |
|---|---|---|
| Log transformation | Right-skewed positive values | log(1 + income) |
| Fixed-width binning | Natural equal ranges | Age in 10-year bands |
| Quantile binning | Skewed values, equal-sized groups | Spend in quartiles |
| Feature splitting | Compound values hide patterns | Timestamp into hour, weekday, month |
Split the timestamp
Predicting taxi tips
A linear model predicts taxi tips from fare amount and pickup time. Fare is heavily skewed (most trips under 20, some over 300), and the raw timestamp gives the model no useful signal.
- Apply
log(1 + fare)so a few long airport trips do not dominate the fitted line. - Split the timestamp into hour, day of week and is_weekend; encode hour with sine and cosine.
- Bin trip distance into quantiles to capture the non-linear effect of short trips.
These changes let a simple, interpretable model learn the rush-hour and weekend patterns that were hidden in the raw timestamp.
Which transformation suits right-skewed values such as income?
Show answer
A log transformation, which compresses the long tail.
Exam Tips
Remember for the exam
- Right-skewed values: log transformation.
- Quantile binning handles skewed distributions.
- Split timestamps into hour, weekday and month.
- Encode cyclical features with sine and cosine.
- Invert the log transform when predicting a log-transformed target.