Feature Scaling
Feature scaling changes the range of numerical features so that features with very different values can be used more fairly by machine learning models.
Feature scaling puts numerical features onto comparable scales.
For example, Age might range from 18 to 80, while Income might range from ₹20,000 to ₹20,00,000. Scaling transforms these values into a more comparable numerical range.
Why Do We Need Feature Scaling?
Imagine a dataset with two numerical features:
18 – 80
₹20,000 – ₹20,00,000
Both features may be useful, but their numerical ranges are very different.
Age contains relatively small numbers, while Income contains much larger numbers.
A Simple Example
Suppose we have two customers:
Notice the difference in the numbers:
Income has much larger numerical values than Age or Orders.
Some algorithms use distances or mathematical calculations involving these features. In those situations, a feature with a large range can have a much stronger influence.
What Does Scaling Do?
Scaling transforms the original values into values on a different numerical scale.
₹50,000
₹1,00,000
Smaller standardized values
The important point is that we are not changing the meaning of the feature. We are changing its numerical representation.
Min-Max Scaling
One common scaling method is called Min-Max Scaling.
It transforms values into a chosen range, commonly between 0 and 1.
For example, suppose the Age values are:
After Min-Max Scaling, the smallest value becomes 0 and the largest value becomes 1, with the other values placed between them.
The exact transformed values depend on the minimum and maximum values in the data.
Standardization
Another common approach is Standardization.
Instead of forcing values into a 0–1 range, standardization transforms values based on their mean and standard deviation.
Standardization is commonly used with algorithms that work better when features are centered and measured on comparable scales.
You do not need to memorize the mathematical formula yet. The important beginner concept is that standardization changes the scale based on the distribution of the data.
Which Models Care More About Scaling?
Not every machine learning algorithm is affected by feature scale in the same way.
Uses distances between data points.
Scaling can help optimization and make feature magnitudes more comparable.
Tree splits are based on feature thresholds rather than distance between feature values.
So feature scaling is not something you blindly apply to every model. It depends on the algorithm.
Real-World Example
Imagine we want to use KNN to find customers who are similar to each other.
We use two features:
20 – 60
₹2,00,000 – ₹20,00,000
KNN calculates distances between customers.
Because Income contains much larger numbers than Age, Income can dominate the distance calculation if the features are not appropriately scaled.
Scaling helps prevent the larger numerical range of Income from dominating simply because of its units.
Scaling Does Not Mean Making Everything Equal
This is a common beginner misunderstanding.
Feature scaling does not mean that Age and Income become the same feature or contain the same information.
Income = ₹1,00,000
Same underlying information
Scaling changes the numerical scale, not the underlying meaning of the feature.
Scaling Makes Numerical Features More Comparable.
When features have very different numerical ranges, certain algorithms can be affected by those differences. Feature scaling transforms the numerical values so that the model can work with more comparable scales.
Do We Need Scaling?
Income: ₹2L–₹20L Different ranges → scaling may be useful
Age and Income have very different ranges, so scaling may be useful, especially for algorithms such as KNN that use distances. Decision Trees generally do not require feature scaling because their splitting logic is not based on feature distance.