scikit-learn 1 · Preprocessing and pipelines

Scale features

Standardize to zero mean and unit variance. Fit on training data only, then transform both sets.

from sklearn.preprocessing import StandardScaler

scaler = StandardScaler().fit(X_train)
X_train_scaled = scaler.transform(X_train)
X_test_scaled = scaler.transform(X_test)

Official scikit-learn 1 documentation

More preprocessing and pipelines commands

All preprocessing and pipelines commands · scikit-learn 1 cheatsheet

Was this page helpful?