---
source: https://iinventedlight.com/library/notes/sklearn-pipelines.md
title: "scikit-learn Pipelines"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (scikit-learn/scikit-learn COPYING; Copyright (c) 2007-2026 The scikit-learn developers; https://github.com/scikit-learn/scikit-learn/blob/main/COPYING); prose restates or closely paraphrases cited source lines"
license_family: sklearn-bsd3
rule_check: "needs rule check (family not in auto-publish rule; check.mjs auto-approves only usgov and arxiv-ccby)"
attribution: "Summary by iinventedlight (AI-assisted). Sources: scikit-learn docs, 8.1. Pipelines and composite estimators — scikit-learn 1.9.1 documentation, BSD-3-Clause (scikit-learn/scikit-learn COPYING; Copyright (c) 2007-2026 The scikit-learn developers; https://github.com/scikit-learn/scikit-learn/blob/main/COPYING); scikit-learn docs, Getting Started — scikit-learn 1.9.1 documentation, BSD-3-Clause (scikit-learn/scikit-learn COPYING; Copyright (c) 2007-2026 The scikit-learn developers; https://github.com/scikit-learn/scikit-learn/blob/main/COPYING)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-04
as_of: 2026-11-04
confidence: medium
untested: "No code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-ai-eng: scikit-learn"
tags: ['scikit-learn', 'pipeline', 'preprocessing']
sources:
  - id: S1
    title: "8.1. Pipelines and composite estimators — scikit-learn 1.9.1 documentation"
    publisher: scikit-learn docs
    url: https://scikit-learn.org/stable/modules/compose.html
    accessed: 2026-11-04
    license: "BSD-3-Clause (scikit-learn/scikit-learn COPYING; Copyright (c) 2007-2026 The scikit-learn developers; https://github.com/scikit-learn/scikit-learn/blob/main/COPYING)"
  - id: S2
    title: "Getting Started — scikit-learn 1.9.1 documentation"
    publisher: scikit-learn docs
    url: https://scikit-learn.org/stable/getting_started.html
    accessed: 2026-11-04
    license: "BSD-3-Clause (scikit-learn/scikit-learn COPYING; Copyright (c) 2007-2026 The scikit-learn developers; https://github.com/scikit-learn/scikit-learn/blob/main/COPYING)"
---
# scikit-learn Pipelines

**Answer:** Transformers and estimators (predictors) can be combined together into a single unifying object: a Pipeline. The pipeline offers the same API as a regular estimator: it can be fitted and used for prediction with fit and predict. (S2)

## Why use one

- Pipeline can be used to chain multiple estimators into one. (S1)
- You only have to call fit and predict once on your data to fit a whole sequence of estimators. (S1)
- You can grid search over parameters of all estimators in the pipeline at once. (S1)
- Pipelines help avoid leaking statistics from your test data into the trained model in cross-validation, by ensuring that the same samples are used to train the transformers and predictors. (S1)

## Rules

- Pipelines require all steps except the last to be a transformer. (S1)
- A pipeline exposes all methods provided by the last estimator. (S1)
- A typical pipeline consists of a pre-processing step that transforms or imputes the data, and a final predictor that predicts target values. (S2)
- FeatureUnion concatenates the output of transformers into a composite feature space. (S1)

## Claims
- id: C1
  claim: A Pipeline has the same API as an estimator.
  source: S2
  evidence: "offers the same API as a regular estimator"
- id: C2
  claim: All steps except the last must be transformers.
  source: S1
  evidence: "Pipelines require all steps except the last to be a"
- id: C3
  claim: Pipelines help avoid leaking test statistics.
  source: S1
  evidence: "Pipelines help avoid leaking statistics from your test data into the"
- id: C4
  claim: You can grid search over all pipeline parameters.
  source: S1
  evidence: "over parameters of all estimators in the pipeline at once."

## Sources
- [S1] 8.1. Pipelines and composite estimators — scikit-learn 1.9.1 documentation. scikit-learn docs. https://scikit-learn.org/stable/modules/compose.html . License: BSD-3-Clause (scikit-learn/scikit-learn COPYING; Copyright (c) 2007-2026 The scikit-learn developers; https://github.com/scikit-learn/scikit-learn/blob/main/COPYING). Accessed 2026-11-04.
- [S2] Getting Started — scikit-learn 1.9.1 documentation. scikit-learn docs. https://scikit-learn.org/stable/getting_started.html . License: BSD-3-Clause (scikit-learn/scikit-learn COPYING; Copyright (c) 2007-2026 The scikit-learn developers; https://github.com/scikit-learn/scikit-learn/blob/main/COPYING). Accessed 2026-11-04.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
