Menu

Feature Scaling Explained

Feature Scaling Explained

Feature scaling adjusts the range of numerical data so all features contribute equally to a model, rather than one feature dominating simply because its numbers are larger.

Why feature scaling matters

  • Algorithms like KNN and SVM are sensitive to data scale.
  • Features with large ranges can unfairly dominate the model's calculations.
  • Scaling helps models train faster and more accurately.

Min-Max Scaling

This method rescales values to a fixed range, usually between 0 and 1.

from sklearn.preprocessing import MinMaxScaler

scaler = MinMaxScaler()

df[["Age", "Salary"]] = scaler.fit_transform(df[["Age", "Salary"]])

fit_transform() calculates the minimum and maximum values of each column, then rescales every value based on that range.

Standardization

This method rescales data to have a mean of 0 and a standard deviation of 1.

from sklearn.preprocessing import StandardScaler

scaler = StandardScaler()

df[["Age", "Salary"]] = scaler.fit_transform(df[["Age", "Salary"]])

This is useful when your data follows a roughly normal distribution, and it is one of the most commonly used scaling methods in machine learning.

Feature scaling ensures that no single feature overpowers the model just because of its raw numerical size.


Machine Learning Tutorial

AP

Abhishek Pati



Learn via Video Course

Artificial Intelligence and Machine Learning Course Logo

Artificial Intelligence and Machine Learning Course

55 hrs



Get in Touch For Details