Skip to content

sklearn/prefit-before-cross-validation

Pack Severity Fix Versions
scikit-learn error none, edit by hand All versions

Refit preprocessing inside every cross-validation fold.

scaled = StandardScaler().fit_transform(X)
scores = cross_val_score(model, scaled, y)
scores = cross_val_score(make_pipeline(StandardScaler(), model), X, y)
Fit preprocessing within each fold by passing an unfitted Pipeline to cross-validation.

See all rules in the scikit-learn pack.