← Zurück zur Akademie
An instructor points to one of two plots on a laptop while a student compares them with sketches in his notebook.
KI-WissenKern1. Nov. 2026· 2 Min.

Feature Scaling Before Modeling

Feature scaling changes the units a model sees, not the underlying observations. This lesson contrasts standardization with range scaling and shows why a scaler must be fitted on training data alone.

feature scalingstandardizationdata preprocessing

Quellen

Vollständige Zusammenfassung

Start with five soil samples whose moisture is recorded in grams of water per kilogram of dry soil. The five readings are 180, 220, 260, 300, and 340. The training mean is 260, and the training standard deviation is the square root of 3200, which is 56.57, or 56.6. Standardization subtracts the mean and divides by that standard deviation, yielding z-scores of -1.41, -0.71, 0, 0.71, and 1.41. The observations have not changed. Only the units and the center have. A model now reads each sample as a distance from typical moisture measured in units of spread.

Now record the same five samples in percent moisture instead. The numbers become 18, 22, 26, 30, and 34. Standardization again yields -1.41, -0.71, 0, 0.71, and 1.41. The lesson is plain. Standardization makes the result independent of the original unit, so a feature in grams and a feature in percent can be compared on a common footing. This matters for estimators whose objective functions weigh features together, such as distance-based methods or regularized linear models.

Min–max scaling uses the lowest and highest training observations as anchors. Before adding a sample, the moisture reading of 260 sits halfway between 180 and 340. Add a very wet sample with a reading of 900 and refit. Now 260 is only 80 units above the minimum in a range of 720, so its scaled value is about 0.11. The extreme reading also changes the mean and standard deviation used in standardization. Either transformation can respond strongly to outliers. Inspect what happens to the measurements that actually distinguish your examples.

Not every estimator needs scaling. Tree-based models split on thresholds within a single feature, so monotone rescaling leaves their splits intact. Scaling is a choice tied to the model, not a universal ritual. A teacher might say, "We scale because this model compares features by size, not because scaling is always good."

Then there is the test set. A scaler learns a training mean and standard deviation. Those are fitted parameters. If you compute the mean from test cases and use it to transform them, information from the test set has shaped the model, and your evaluation no longer reflects unseen data. Fit the scaler on training data, then apply that same fitted transformation to test data. In code this is a pipeline that fits on training rows and scores on test rows.

Give pairs a short column of hypothetical reaction times and ask them to standardize by hand, then add one extreme value and repeat. Have each pair write the before and after values on the board and explain which summary moved more. Visible arithmetic makes their reasoning inspectable, and the discussion naturally separates changing units from changing evidence. When a student asks why the test set cannot have its own mean, point out that a test mean would be a peek at the future, and the model must face the future with only the past in hand.