sklearn/scaler-fit-before-split
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| scikit-learn | info | none, edit by hand | All versions |
Fit scalers and imputers on training rows only.
scaled = StandardScaler().fit_transform(X)X_train, X_test = train_test_split(scaled)X_train, X_test = train_test_split(X)scaler = StandardScaler().fit(X_train)Diagnostic message
Section titled “Diagnostic message”Split the rows before fitting this scaler or imputer, or fit it inside a Pipeline.See all rules in the scikit-learn pack.