How can numerical features be transformed?
Numerical features can be transformed to make their scale, distribution, or relationship with the target easier for a machine learning model to use.
1. Scale the feature
Numerical values can be rescaled using methods such as normalization or standardization.
This is useful when features have very different ranges and the algorithm is sensitive to magnitude.
2. Apply a logarithmic transformation
A log transformation can reduce strong right-skew in features such as:
- income
- transaction amount
- population
- website traffic
For example:
10, 100, 1000becomes roughly:
1, 2, 3when using a base-10 logarithm.
This compresses very large values more than small ones.
3. Use square-root or power transformations
Square-root, Box-Cox, or Yeo-Johnson-style transformations can also change the shape of a numerical distribution.
They may help when the feature is strongly skewed or its relationship with the target is nonlinear.
4. Clip or cap extreme values
Very large or very small values can sometimes be limited to chosen boundaries.
For example, values above the 99th percentile may be capped at that threshold when there is a clear modeling reason to reduce extreme influence.
This should not be done automatically without understanding the outliers.
5. Bin continuous values
A continuous feature can be grouped into ranges.
For example:
Age 18–25 → Young
Age 26–40 → Adult
Age 41–60 → MiddleBinning can simplify relationships, but it also loses some numerical detail.
6. Create ratios or interaction features
Existing numerical features can be combined to create more meaningful values.
Examples include:
price_per_unit = price / quantitydebt_to_income = debt / incomedistance_per_hour = distance / time
These derived features may represent the real-world relationship better than the original columns separately.
Choose transformations using validation
A transformation should have a clear reason and should be evaluated on validation data.
Transforming a feature does not automatically improve a model.
Fit learned transformations on training data only
Any transformation that learns statistics from the data—such as scaling parameters, percentile thresholds, or power-transform parameters—should be fitted on the training set and then applied unchanged to validation and test data.
In short, numerical features can be transformed through scaling, log or power transforms, clipping, binning, or derived ratios to make useful patterns easier for a model to learn.
Learning Sequence
Machine Learning Curriculum
Explore Related Questions
Deepen your understanding across related Machine Learning topics.