Min-Max Scaling
Squeeze into 0 to 1.
Sometimes you want every feature squeezed between zero and one. For example, pixel brightness in images, or inputs to some neural networks. That's min max scaling.

- Squeeze into 0 to 1
- Pixels, neural networks
- Min-max scaling
The formula
Subtract the minimum, and divide by the range. The smallest value becomes zero, and the largest becomes one. Everything else lands in between, in proportion. Run it. Twenty, thirty five, and fifty become zero, a half, and one.
import numpy as np
ages = np.array([20, 35, 50, 26, 44])
scaled = (ages - ages.min()) / (ages.max() - ages.min())
print(scaled.round(2))[0. 0.5 1. 0.2 0.8]
Which scaler?
Standardizing is the usual default. It's less affected by a single extreme value. Min max scaling gives a fixed range, which is nice for images and some neural networks, but one outlier can squash everything else into a tiny range. Tree models, like random forests, don't need scaling at all.
StandardScaler
- mean 0, std 1the usual defaulthandles outliers better
MinMaxScaler
- range 0 to 1images, some networksoutliers squash the rest
Summary
Min max scaling maps the smallest value to zero and the largest to one. Standardizing is usually the safer default. Next, a quiz on spread and scaling.
Key takeaways- (x − min) / (max − min)
- 0 to 1
- Outliers can squash it