liveBook · Manning

StandardScaler

As explained in Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI

StandardScaler is a Scikit-learn transformer that standardizes numeric features using statistics learned from fitting data.

StandardScaler standardizes numeric features by learning each feature’s mean and standard deviation from fitting data, then applying those statistics to transform data. section 4.1.2

Use the transformer in two distinct steps:

  • Fit it on training data so the scaler learns transformation parameters. section 4.1.2
  • Transform new, validation, or test data with the fitted scaler, avoiding information leakage between datasets. section 4.1.2
from sklearn.preprocessing import StandardScaler
processing = StandardScaler().fit(X)

Instantiate StandardScaler and fit it to feature data, retaining the learned preprocessing parameters for later transformations. section 4.1.2

processing.fit_transform(X)

Fit and transform the same data in one operation when that workflow is appropriate; separate fitting and transformation when controlling dataset boundaries. section 4.1.2

How Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI covers it

How deep it goes
Explains learned means and standard deviations, fitting, transformation, and leakage prevention without deriving the scaling formula.
Examples
Uses StandardScaler().fit(X), transform(X), and fit_transform(X) as the core examples.
What it assumes
Assumes familiarity with feature matrices and Scikit-learn’s fit-transform interface.
What you can do after
Apply StandardScaler to learn feature statistics and transform data without mixing training and evaluation information.
How it connects
Connects preprocessing with data pipelines and training, validation, and test-data separation.

Also explained in

Compare how 2 books explain StandardScaler →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI. The section links point to the parts of the book it draws on.