Build a repeatable baseline with preprocessing, a model, validation and a held-out test.
This is one focused step in the 60-lesson course. Use the retrieval check before moving on.
Lesson goal
Build a repeatable baseline with preprocessing, a model, validation and a held-out test.
The core idea
A pipeline is a contract: the same transformations applied during training are applied in the same order during inference.
Mental model
Picture it this way. A pipeline is a contract: the same transformations applied during training are applied in the same order during inference. The important question is what assumption this picture makes, and whether that assumption fits the data.
Mathematical core
A scikit-learn Pipeline composes transformations and an estimator. Cross-validation scores the whole pipeline, which helps prevent preprocessing leakage.
Worked example
A tabular cancellation baseline can impute missing values, one-hot encode categories and fit logistic regression inside one pipeline.
When to use it
It earns a place when
Use a baseline before searching a large hyperparameter space. It gives a reference point and exposes data problems.
You can evaluate it against a credible baseline.
Its output fits the decision and data constraints.
Do not make it the default when
Do not compare models after applying different preprocessing outside the split, and do not treat a baseline as the final model.
A simpler model has not been tested.
The data or target definition is still unclear.
Failure modes
Watch for this. A pipeline can be technically correct while the target definition, split or metric is wrong.
When a result looks surprisingly good, inspect the split, target timing, error slices and data-generating process before celebrating.
Practice
Use this as a small experiment rather than a recipe to copy blindly. Change one thing, record the result and explain the change.
Do this. Run the skeleton below on a small labelled table. Record the split, metric, score and one observed limitation.
Retrieval check
Answer from memory first. The buttons reveal feedback, but the durable step is explaining why.
1. What does a Pipeline help guarantee?
2. Why should preprocessing be fitted inside cross-validation?
3. What is a baseline for?
Transfer prompt. Describe one real problem where this model or idea would be a sensible candidate. Name the target, the main risk and the metric you would inspect.
Primary source
scikit-learn User Guide. Use the source for the deeper treatment after you can explain the lesson's core idea without looking.