D Dev Duniya
Back to Journal
4 min read

Normalization, Scaling, and Standardization in Machine Learning - DevDuniya

Ashish Yadav

Ashish Yadav

Published on Dev Duniya
Keep exploring
Compare the details before you buy.

Machine learning models rely heavily on the quality and consistency of data. One critical step in data preprocessing is ensuring that the features in the dataset are properly scaled. This process can significantly affect the performance of the model. In this blog, we'll dive deep into Normalization, Scaling, and Standardization, explaining their concepts, differences, and when to use each technique.

What is Data Scaling in Machine Learning?

Data scaling is the process of transforming data into a specific range or distribution to ensure all features contribute equally to the model. It is particularly important for machine learning algorithms that rely on the distance between data points, such as:

  • Support Vector Machines (SVMs)
  • K-Nearest Neighbors (KNN)
  • Principal Component Analysis (PCA)
  • Gradient-based models like Neural Networks

Without scaling, features with larger numerical ranges could dominate the learning process, making the model biased and less accurate.

What is Normalization?

Normalization is the process of adjusting the values of a feature to a range between 0 and 1. It is a type of scaling where we transform data to make it fit within a specific scale while preserving the relationships between the data points.

Formula for Normalization:

When to Use Normalization?

Normalization is best used when:

  • You know the data follows a non-Gaussian distribution.
  • You are using algorithms sensitive to the scale of data, such as KNN or Neural Networks.
  • The dataset contains features that have varying units or scales.

Example:

FeatureRaw ValueNormalized Value
Feature 1100
Feature 1150.33
Feature 1200.67
Feature 1301

Swipe sideways to see all table columns →

Feature
Feature 1
Raw Value
10
Normalized Value
0
Feature
Feature 1
Raw Value
15
Normalized Value
0.33
Feature
Feature 1
Raw Value
20
Normalized Value
0.67
Feature
Feature 1
Raw Value
30
Normalized Value
1

What is Standardization?

Standardization transforms data to have a mean of 0 and a standard deviation of 1. It centers the data and rescales it based on the standard deviation.

Formula for Standardization:

Where:

  • μ = mean of the feature
  • σ = standard deviation of the feature

When to Use Standardization?

Standardization is used when:

  • The algorithm assumes a Gaussian (normal) distribution of the features.
  • You are working with algorithms such as PCA, Logistic Regression, or Linear Regression.
  • The dataset contains outliers, as standardization is less sensitive to extreme values compared to normalization.

Example:

FeatureRaw ValueStandardized Value
Feature 110-1.14
Feature 115-0.71
Feature 1200
Feature 1301.14

Swipe sideways to see all table columns →

Feature
Feature 1
Raw Value
10
Standardized Value
-1.14
Feature
Feature 1
Raw Value
15
Standardized Value
-0.71
Feature
Feature 1
Raw Value
20
Standardized Value
0
Feature
Feature 1
Raw Value
30
Standardized Value
1.14

What is Scaling?

Scaling adjusts the magnitude of data without changing its distribution. It ensures that all features contribute equally to the model by fitting them within a specific range or distribution.

Types of Scaling:

  1. Min-Max Scaling: Equivalent to normalization.
  2. Max Abs Scaling: Scales features by dividing them by their maximum absolute value.
  3. Robust Scaling: Uses the median and the interquartile range (IQR) to scale data, making it robust to outliers.

Key Differences Between Normalization, Standardization, and Scaling

AspectNormalizationStandardizationScaling
PurposeFit data in a fixed range, e.g., 0 to 1.Center data to have mean = 0, std dev = 1.Adjust magnitude without changing distribution.
Best ForNeural Networks, KNN, SVM.PCA, Logistic/Linear Regression.Situations requiring general adjustments.
Sensitivity to OutliersSensitiveLess SensitiveDepends on the scaling method.

Swipe sideways to see all table columns →

Aspect
Purpose
Normalization
Fit data in a fixed range, e.g., 0 to 1.
Standardization
Center data to have mean = 0, std dev = 1.
Scaling
Adjust magnitude without changing distribution.
Aspect
Best For
Normalization
Neural Networks, KNN, SVM.
Standardization
PCA, Logistic/Linear Regression.
Scaling
Situations requiring general adjustments.
Aspect
Sensitivity to Outliers
Normalization
Sensitive
Standardization
Less Sensitive
Scaling
Depends on the scaling method.

How to Implement in Python

Here's a simple example of how to use each technique in Python using the scikit-learn library.

Normalization:

from sklearn.preprocessing import MinMaxScaler

scaler = MinMaxScaler()
normalized_data = scaler.fit_transform(data)

Standardization:

from sklearn.preprocessing import StandardScaler

scaler = StandardScaler()
standardized_data = scaler.fit_transform(data)

Scaling:

from sklearn.preprocessing import RobustScaler

scaler = RobustScaler()
scaled_data = scaler.fit_transform(data)

When Should You Use These Techniques?

  1. Normalization: Use when you know the data distribution is not Gaussian, and the algorithm depends on data magnitude.
  2. Standardization: Use when the data follows a Gaussian distribution or when outliers are present.
  3. Scaling: Use as a general preprocessing step when data values vary significantly.

Common Mistakes to Avoid

  1. Ignoring Outliers: If your data has many outliers, normalization might not be the best choice.
  2. Using the Wrong Technique: Match the scaling method to the algorithm you are using.
  3. Not Scaling Test Data: Always apply the same transformation to the test data as you do to the training data to avoid inconsistencies.

Normalization, scaling, and standardization are essential preprocessing steps in machine learning. Understanding their nuances and applying them correctly can drastically improve your model's performance. Always analyze your data and choose the method that best aligns with your algorithm and data distribution.

Keep reading

12 latest articles

The newest stories from Dev Duniya, excluding the article you are reading.

All articles →

From the product catalog

Explore device specifications

Specification cards update automatically from published catalog products, grouped by brand.

Apple specifications

Explore Apple devices →
Apple Apple MacBook Pro 14-inch
Apple Apple MacBook Pro 14-inch specifications

Experience unrivaled performance with the latest Apple MacBook Pro, available in 14-inch and 16-inch models powered by the revolutionary M6, M5 Pro, and M5 Max chips. Built for Apple Intelligence, these powerhouse laptops feature advanced Thunderbolt 5 ports, Wi-Fi 7, and optional Nano-texture displays for minimal glare. Maximize your creative potential with up to 128GB of unified memory in a sleek Space Black or Silver finish.

Display size
14-inch
Screen Type
Standard display (low reflectivity) or Nano-texture display (reduces reflections and glare in bright lighting)
External Display Support
Support for up to three external displays (M5 Pro) / Support for up to four external displays (M5 Max)
M6 Chip
12‑core CPU, 12‑core GPU, Dual 16‑core Neural Engine
See all specifications →
Apple Apple MacBook Pro 16-inch
Apple Apple MacBook Pro 16-inch specifications

Experience unrivaled performance with the latest Apple MacBook Pro, available in 14-inch and 16-inch models powered by the revolutionary M6, M5 Pro, and M5 Max chips. Built for Apple Intelligence, these powerhouse laptops feature advanced Thunderbolt 5 ports, Wi-Fi 7, and optional Nano-texture displays for minimal glare. Maximize your creative potential with up to 128GB of unified memory in a sleek Space Black or Silver finish.

Display size
16-inch
Screen Type
Standard display (low reflectivity) or Nano-texture display (reduces reflections and glare in bright lighting)
External Display Support
Support for up to three external displays (M5 Pro) Support for up to four external displays (M5 Max)
M5 Pro Chip
18‑core CPU, 20‑core GPU, 16‑core Neural Engine
See all specifications →
Apple Apple iPhone Duo
Apple Apple iPhone Duo specifications

Apple iPhone Duo is a new-generation iPhone model focused on a sleek design, powerful performance, and everyday usability. Explore iPhone Duo specifications, features, display, cameras, battery, and expected price in the USA. Get the latest information about Apple iPhone Duo and its key features. Compare iPhone Duo with other popular Apple iPhone models.

Size (inches)
Open: 4.64 x 6.48 x 0.21 Closed: 4.64 x 3.31 x 0.44
Weight (ounces)
8.96
Display size (inches)
Inner: 7.6-inch (diagonal) all-screen OLED folding display Outer: 5.4-inch (diagonal) all-screen OLED display
Resolution (pixels)
Inner: 1878-by-2670-pixel resolution at 430 ppi Outer: 1398-by-2034-pixel resolution at 460 ppi
See all specifications →
Apple Apple iPhone 18 Pro Max
Apple Apple iPhone 18 Pro Max specifications

Apple iPhone 18 Pro Max is a high-end flagship smartphone designed for powerful performance and advanced photography. Explore iPhone 18 Pro Max specifications, features, display, cameras, battery, and expected price in the USA. Discover the latest upgrades and key features of Apple’s largest Pro iPhone. Compare iPhone 18 Pro Max with other premium flagship smartphones.

Size (inches)
6.43 x 3.07 x 0.34
Weight (ounces)
8.78
Display size (inches)
6.9-inch (diagonal) all-screen OLED display
Resolution (pixels)
2868-by-1320-pixel resolution at 460 ppi
See all specifications →
Apple Apple iPhone 18 Pro
Apple Apple iPhone 18 Pro specifications

Apple iPhone 18 Pro is a premium flagship smartphone with advanced performance and an upgraded camera system. Explore iPhone 18 Pro specifications, features, display, cameras, battery, and expected price in the USA. Get the latest details about Apple’s new Pro model and its key upgrades. Compare iPhone 18 Pro features with other flagship smartphones.

Size (inches)
5.91 x 2.83 x 0.34
Weight (ounces)
7.44
Display size (inches)
6.3-inch (diagonal) all-screen OLED display
Resolution (pixels)
2622-by-1206-pixel resolution at 460 ppi
See all specifications →

Google specifications

Explore Google devices →
Google Google Pixel 12
Google Google Pixel 12 specifications

Upgrade to the Google Pixel 12, an advanced 5G AI smartphone. Experience seamless performance powered by the custom Google Tensor G7 processor. Enjoy a stunning 6.3-inch OLED Actua display and take flawless photos with the powerful 50MP dual-camera system. Built with an adaptive all-day battery and seamless Google Gemini AI integration, it is the perfect unlocked device for everyday brilliance.

Size (inches)
6.02 x 2.83 x 0.34
Weight (ounces)
6.95
Display size (inches)
6.3-inch (diagonal) OLED display
Resolution (pixels)
1080 x 2424 pixels
See all specifications →
Google Google Pixel 12 Pro
Google Google Pixel 12 Pro specifications

Discover the new Google Pixel 12 Pro, the ultimate 5G AI smartphone. Powered by the next-generation Google Tensor G7 chip and built-in Gemini AI, it delivers blazing-fast performance. Capture professional-grade photos with the advanced 50MP Pro Triple Camera system featuring 5x optical zoom. Complete with a stunning 6.3-inch Super Actua display, all-day adaptive battery, and a premium titanium frame. Upgrade to the smartest Android phone today.

Size (inches)
6.02 x 2.83 x 0.33
Weight (ounces)
7.3
Display size (inches)
6.31-inch LTPO OLED display
Resolution (pixels)
2856 x 1280 pixels
See all specifications →
Google Google Pixel 12 Pro XL
Google Google Pixel 12 Pro XL specifications

Go bigger with the Google Pixel 12 Pro XL, the ultimate large-screen 5G AI smartphone. It boasts a massive 6.8-inch OLED display and the lightning-fast Google Tensor G7 chip. Capture master-level photography using the 50MP Pro Triple Camera setup. Equipped with a massive 5500mAh battery for extended endurance and fast 67W charging, this unlocked flagship redefines premium power.

Size (inches)
6.43 x 3.07 x 0.34
Weight (ounces)
8.18
Display size (inches)
6.8-inch LTPO OLED Super Actua display
Resolution (pixels)
2992 x 1344 pixels
See all specifications →
Google Google Pixel 12 Pro Fold
Google Google Pixel 12 Pro Fold specifications

Transform your mobile experience with the Google Pixel 12 Pro Fold. This unlocked 5G AI foldable smartphone unfolds into a gorgeous 8-inch dual-UTG inner OLED display for next-level multitasking and entertainment. Powered by the Google Tensor G7 chip, it features flexible triple-camera photography, advanced Gemini AI, and a highly durable folding hinge design.

Size (inches) - Unfolded
6.24 x 5.64 x 0.16
Size (inches) - Folded
6.24 x 2.87 x 0.35
Weight (ounces)
7.58
Main Display
8.0-inch Foldable LTPO OLED, 120Hz
See all specifications →

Samsung specifications

Explore Samsung devices →