Pipelines

Preparing data is part of fitting a model. If a scaler learns from our test examples, the test has already influenced the result. A pipeline helps us keep those fitting steps together and inside the training procedure.

14 sections · 10 questions · 4 coding challenges

1 / 14

How Do We Repeat the Whole Procedure Without Changing It?

BOTIE

A useful model often depends on several earlier steps: filling missing values, scaling measurements, perhaps reducing dimensions. If we remember to repeat the predictor but forget how those preparations were learned, our evaluation no longer describes the procedure we will use on new data.

Pipelines grew out of this broader software and experimental problem rather than a single new statistical formula. Scikit-learn's 2011 paper describes a library built around consistent interfaces for learning procedures. Its pipeline tools make a sequence of transformations and a predictor behave as one fitted object.

Each learned preparation step fits only on the training data, then passes its result onward. Later observations travel through the stored steps in the same order. During cross-validation, the whole sequence must be fitted again inside each training fold. Packaging the procedure helps us enforce that boundary instead of relying on memory.

Sources for this history