MACHINE LEARNING • LESSON 6

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.

THE SIMPLEST DEFINITION

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.

01

Why Do We Need Feature Scaling?

Imagine a dataset with two numerical features:

FEATURE 1 Age

18 – 80

FEATURE 2 Income

₹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.

The model should care about the information in a feature, not simply because its numbers happen to be much larger.
02

A Simple Example

Suppose we have two customers:

Customer Age Income Orders
Rahul 25 ₹50,000 5
Priya 30 ₹1,00,000 8

Notice the difference in the numbers:

Age 25, 30
Orders 5, 8
Income 50,000, 100,000

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.

03

What Does Scaling Do?

Scaling transforms the original values into values on a different numerical scale.

BEFORE SCALING Income

₹50,000

₹1,00,000

AFTER SCALING Comparable numerical range

Smaller standardized values

The important point is that we are not changing the meaning of the feature. We are changing its numerical representation.

Age is still Age. Income is still Income. Scaling only changes the numerical scale used by the model.
04

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:

20
30
40
50
60

After Min-Max Scaling, the smallest value becomes 0 and the largest value becomes 1, with the other values placed between them.

0
0.25
0.50
0.75
1

The exact transformed values depend on the minimum and maximum values in the data.

05

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.

ORIGINAL VALUES 20, 30, 40, 50, 60
STANDARDIZED VALUES Centered around the mean

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.

06

Which Models Care More About Scaling?

Not every machine learning algorithm is affected by feature scale in the same way.

OFTEN BENEFIT FROM SCALING KNN

Uses distances between data points.

OFTEN BENEFIT FROM SCALING Logistic Regression

Scaling can help optimization and make feature magnitudes more comparable.

GENERALLY NOT REQUIRED Decision Trees

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.

07

Real-World Example

Imagine we want to use KNN to find customers who are similar to each other.

We use two features:

FEATURE 1 Age

20 – 60

FEATURE 2 Annual Income

₹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.

AGE Small range
+
INCOME Very large range
AFTER SCALING More comparable scales

Scaling helps prevent the larger numerical range of Income from dominating simply because of its units.

IMPORTANT

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.

BEFORE Age = 30

Income = ₹1,00,000

AFTER SCALING Different representations

Same underlying information

Scaling changes the numerical scale, not the underlying meaning of the feature.

REMEMBER THIS

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.

QUICK CHECK

Do We Need Scaling?

Age: 20–60
Income: ₹2L–₹20L
Different ranges → scaling may be useful
KNN Uses distances → scaling is often important
Decision Tree Usually does not require feature scaling
Answer

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.

NEXT TOPIC

Splitting Data Correctly

We have cleaned and prepared our features. Next, we will learn how to split the dataset correctly so that the model can be trained and evaluated fairly.