Written and maintained by CASRAI Editorial Board
Last updated
Data normalization means three different things depending on who is speaking. In statistics and machine learning it is rescaling numeric variables so they share a comparable range. In database design it is organizing tables to remove redundancy. In everyday data cleaning it is making formats consistent. This guide covers the first meaning in depth, with working Python and R steps, and gives the database meaning its own short section.
Which meaning of “normalization” do you need?
Libraries and textbooks use the word inconsistently, so check which operation a tutorial actually performs before copying its code.
| Meaning | What it does | Where it appears |
|---|---|---|
| Min-max rescaling | Scales each feature to lie between a given minimum and maximum, often zero and one | scikit-learn MinMaxScaler; the formula (X – min) / (max – min) |
| Standardization | Shifts each feature to zero mean and unit variance | scikit-learn StandardScaler; R scale() |
| Per-sample normalization | Scales each row (sample) to unit norm (l1, l2 or max) | scikit-learn Normalizer and normalize |
| Database normalization | Organizes tables and relationships to remove redundancy and inconsistent dependency | Relational database design (1NF, 2NF, 3NF) |
The scikit-learn documentation defines normalization as “the process of scaling individual samples to have unit norm”, which is a row-wise operation. Many other sources use “normalization” for the column-wise min-max rescaling that scikit-learn files under scalers. Neither usage is wrong; they are different operations sharing a name. For the spreadsheet version of min-max scaling, see how to normalise data in Excel.
What is data normalization used for in research?
Rescaling is used when variables measured in different units or ranges need to be compared or combined. The scikit-learn documentation notes that standardization of datasets is a common requirement for many machine learning estimators, which “might behave badly if the individual features do not more or less look like standard normally distributed data: Gaussian with zero mean and unit variance.” Typical research uses are preparing predictors for distance-based or regularized models, putting several instruments on one scale, and producing z-scores for comparison across groups.
Rescaling is not the same as transforming a skewed distribution. If the aim is to change the shape of the data rather than its range, see log and other data transformations.
How do you install or access the tools?
Both tools below come from their official projects.
- Python: the scaling classes are in scikit-learn’s
sklearn.preprocessingmodule. Install scikit-learn from the official project, then import the classes you need. - R:
scale()is part of base R, so no package installation is needed.
Step-by-step: normalizing and standardizing a dataset
In Python with scikit-learn
- Split your data into training and test sets first. Fit every scaler on the training set only.
- For min-max rescaling, create
MinMaxScaler()and callfit_transformon the training features. The scaler computes, per feature, (X – X.min) / (X.max – X.min), then multiplies by the range you request (often zero to one). - For standardization, create
StandardScaler()and callfit_transformon the training features. - Apply the already-fitted scaler to the test set with
transform(notfit_transform). The scikit-learn documentation describes the reason: the scaler computes the mean and standard deviation on a training set “so as to be able to later re-apply the same transformation on the testing set.”
from sklearn.preprocessing import MinMaxScaler, StandardScaler
mm = MinMaxScaler()
X_train_mm = mm.fit_transform(X_train)
X_test_mm = mm.transform(X_test)
ss = StandardScaler()
X_train_ss = ss.fit_transform(X_train)
X_test_ss = ss.transform(X_test)
To scale each row to unit norm instead, use Normalizer (or the normalize function) with the norm set to l1, l2 or max. Normalizer is stateless and treats each sample independently, so there is nothing to fit on the training set. In the scikit-learn documentation, L2 normalization is also known as spatial sign preprocessing.
In R with scale()
- Put the numeric columns in a matrix-like object (a numeric matrix or data frame of numeric columns).
- Call
scale(x). The defaults arecenter = TRUE, scale = TRUE: it subtracts each column’s mean (ignoring NAs) and then divides each centered column by its standard deviation. - Use
center = FALSEorscale = FALSEto switch either step off.
z <- scale(df[, c("height", "weight")])
attr(z, "scaled:center") # column means
attr(z, "scaled:scale") # column standard deviations
R’s own documentation warns about one detail: with center = FALSE, the columns are divided by their root mean square, sqrt(sum(x^2)/(n-1)), which differs from the standard deviation. Do not assume scale(x, center = FALSE) gives unit-variance columns.
How do you read the output?
- Min-max output: each training feature spans the requested range (often 0 to 1). A test value outside the training minimum and maximum will fall outside that range, because the training minimum and maximum define the formula.
- Standardized output: each training column has mean zero and unit variance, and a value is expressed in standard deviations from the training mean.
- R attributes:
scale()returns the result with attributes"scaled:center"and"scaled:scale". Keep them: they let you reverse the transformation or apply the same one to new data.
For hand calculation and software-specific walk-throughs of z-scores, see calculating z-scores in SPSS and standard deviation in R.
Troubleshooting
My data has outliers
Both min-max rescaling and standardization are driven by extreme values (the range, or the mean and variance). The scikit-learn documentation states: “If your data contains many outliers, scaling using the mean and variance of the data is likely to not work very well. In these cases, you can use RobustScaler as a drop-in replacement instead.” To decide how to treat extreme values before scaling, see winsorizing vs. trimming.
Test-set results look too good
If you called fit or fit_transform on the full dataset before splitting, information from the test set has leaked into training. Fit on the training set only, then apply the fitted scaler to the test set. The CASRAI dictionary defines the problem as data leakage (training).
I need the original values back
Keep the fitted scaler object in Python or the "scaled:center" and "scaled:scale" attributes in R. Without them the transformation cannot be reversed or reapplied to new data.
Free alternatives
| Tool | Rescaling approach | More detail |
|---|---|---|
| Python, scikit-learn | MinMaxScaler, StandardScaler, RobustScaler, Normalizer |
Official preprocessing documentation (see Sources) |
| R, base | scale() with center and scale arguments |
R documentation for scale (see Sources) |
| Spreadsheet | Min-max formula and the STANDARDIZE function | How to normalise data in Excel |
What is data normalization in a database?
In database design, normalization is the process of organizing data in a database. Microsoft’s documentation describes it as creating tables and establishing relationships between them according to rules designed both to protect the data and to make the database more flexible by eliminating redundancy and inconsistent dependency. The first three normal forms are:
- First normal form (1NF): eliminate repeating groups, create a separate table for each set of related data, and identify each set with a primary key.
- Second normal form (2NF): create separate tables for values that apply to multiple records and relate them with a foreign key.
- Third normal form (3NF): eliminate fields that do not depend on the key.
Microsoft’s worked example starts with one table holding student number, advisor, advisor room and three class columns (Class1 to Class3), and splits it into Students, Registration and Faculty tables. The same article says third normal form is considered the highest level necessary for most applications, that the higher forms (Boyce-Codd, fourth and fifth) are rarely considered in practical design, and that full normalization is not always practical because many small tables may degrade performance.
FAQ
What is the difference between normalization and standardization?
Standardization shifts a feature to zero mean and unit variance. Min-max normalization rescales it to a fixed range, often zero to one. In scikit-learn, “normalization” specifically means scaling each sample to unit norm, so check which operation a library function performs.
What is data normalization in a database?
It is organizing tables and relationships to eliminate redundancy and inconsistent dependency, usually to third normal form. It does not change numeric values; it changes how records are stored. See the database section above.
Should I normalize before or after splitting my data?
After. Fit the scaler on the training set, then apply that fitted transformation to the test set.
Which scaler should I use when my data has outliers?
The scikit-learn documentation recommends RobustScaler as a drop-in replacement for mean-and-variance scaling in that situation.
Sources
- scikit-learn documentation, “Preprocessing data”: https://scikit-learn.org/stable/modules/preprocessing.html (checked 2026-10-29)
- R documentation,
scale: https://stat.ethz.ch/R-manual/R-devel/library/base/html/scale.html (checked 2026-10-29) - Microsoft Learn, “Description of the database normalization basics”: https://learn.microsoft.com/en-us/office/troubleshoot/access/database-normalization-description (checked 2026-10-29)








