Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Scikit-Learn · Function

make_pipeline

Constructs a scikit-learn Pipeline from estimators supplied in order. It automatically generates lowercase step names from estimator types.

How it works

Pass transformers and a final estimator in execution order. The function builds a Pipeline, automatically deriving each step name by lowercasing its estimator type; the resulting pipeline can be fitted and used for prediction as a single estimator.

Syntax

sklearn.pipeline.make_pipeline(*steps, memory=None, transform_input=None, verbose=False)

Parameters

NameTypeDescription
stepsestimatorsOrdered estimator objects to chain into the pipeline.
memorystr or object, default=NoneCache location or a joblib.Memory-compatible object; default=None.
transform_inputlist of str, default=NoneNames of fit inputs other than X to transform through relevant preceding steps; default=None.
verbosebool, default=FalseWhether to print elapsed fitting time for each step; default=False.

Returns

A scikit-learn Pipeline object.

Key points

  • The function creates a Pipeline from the estimators passed as positional steps.
  • Step names are generated automatically by lowercasing each estimator's type name.
  • The positional steps form an ordered chain of scikit-learn estimators.
  • The memory option can cache fitted transformer steps.
  • verbose=True prints elapsed fitting time after each step completes.

Common mistakes

  • Enabling memory caching does not cache the final pipeline step.
  • With memory caching enabled, inspect the fitted clones through the pipeline rather than relying on the original transformer objects.

Example: Scale features and classify

from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler

X, y = load_iris(return_X_y=True)
model = make_pipeline(StandardScaler(), LogisticRegression(max_iter=200))
model.fit(X, y)
print(model.predict(X[:3]))

Standardizes the features and then fits a logistic-regression classifier as one estimator.

When to use it

End-to-end modeling

Combine preprocessing and prediction into one fit/predict object.

Consistent preprocessing

Reuse the same transformation sequence during validation and inference.

Transformer caching

Avoid repeating expensive transformer fitting across compatible runs.

Interview questions

QWhat does make_pipeline provide compared with Pipeline?

make_pipeline accepts a variable number of estimators and returns a Pipeline containing them in the supplied order. It automatically names each step from the lowercase estimator type, so explicit step names are not provided.

Follow-up: When are explicit names preferable? Use Pipeline when stable, custom names are needed for parameter searches or inspection.

QHow are the supplied estimators used?

The steps are chained sequentially: transformers process the data before the final estimator receives it. The returned Pipeline exposes the composite estimator interface, including fitting and prediction when its last step supports those operations.

Follow-up: How would you inspect a particular step? Access the pipeline's named_steps or steps attributes.

QWhat does the memory parameter do?

memory accepts a path or an object implementing the joblib.Memory interface. It caches fitted transformers, while caching is disabled by default and the final step is excluded from caching.

Follow-up: What additional behavior should be considered when caching? Transformer instances are cloned before fitting, so inspect the fitted pipeline steps.

  • Pipeline
  • make_union
  • FeatureUnion

Source: make_pipeline — scikit-learn 1.9.1 documentation. Checked 2026-10-15.