Why use an sklearn pipeline?
Reveal the answer and explore the explanation.
10HardWhy use an sklearn pipeline?
Answer
Hard
Why use an sklearn pipeline?
Answer
Chains fitted preprocessing and modeling steps consistently.
Practical example
Cross-validate scaling and a classifier as one estimator.
PythonRelated concept example
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
model = make_pipeline(StandardScaler(), LogisticRegression())
# Fit model on training data only.A pipeline keeps fitted preprocessing inside cross-validation.
Reference: Further reading ↗