make_pipeline#

sklearn.pipeline.make_pipeline(*steps,memory=None,transform_input=None,verbose=False)[source]#

Construct aPipeline from the given estimators.

This is a shorthand for thePipeline constructor; it does notrequire, and does not permit, naming the estimators. Instead, their nameswill be set to the lowercase of their types automatically.

Parameters:
*stepslist of Estimator objects

List of the scikit-learn estimators that are chained together.

memorystr or object with the joblib.Memory interface, default=None

Used to cache the fitted transformers of the pipeline. The last stepwill never be cached, even if it is a transformer. By default, nocaching is performed. If a string is given, it is the path to thecaching directory. Enabling caching triggers a clone of the transformersbefore fitting. Therefore, the transformer instance given to thepipeline cannot be inspected directly. Use the attributenamed_stepsorsteps to inspect estimators within the pipeline. Caching thetransformers is advantageous when fitting is time consuming.

transform_inputlist of str, default=None

This enables transforming some input arguments tofit (other thanX)to be transformed by the steps of the pipeline up to the step which requiresthem. Requirement is defined viametadata routing.This can be used to pass a validation set through the pipeline for instance.

You can only set this if metadata routing is enabled, which youcan enable usingsklearn.set_config(enable_metadata_routing=True).

Added in version 1.6.

verbosebool, default=False

If True, the time elapsed while fitting each step will be printed as itis completed.

Returns:
pPipeline

Returns a scikit-learnPipeline object.

See also

Pipeline

Class for creating a pipeline of transforms with a final estimator.

Examples

>>>fromsklearn.naive_bayesimportGaussianNB>>>fromsklearn.preprocessingimportStandardScaler>>>fromsklearn.pipelineimportmake_pipeline>>>make_pipeline(StandardScaler(),GaussianNB(priors=None))Pipeline(steps=[('standardscaler', StandardScaler()),                ('gaussiannb', GaussianNB())])

Gallery examples#

Time-related feature engineering

Time-related feature engineering

Plot classification probability

Plot classification probability

Classifier comparison

Classifier comparison

A demo of K-Means clustering on the handwritten digits data

A demo of K-Means clustering on the handwritten digits data

Principal Component Regression vs Partial Least Squares Regression

Principal Component Regression vs Partial Least Squares Regression

Feature transformations with ensembles of trees

Feature transformations with ensembles of trees

Categorical Feature Support in Gradient Boosting

Categorical Feature Support in Gradient Boosting

Combine predictors using stacking

Combine predictors using stacking

Visualizing the probabilistic predictions of a VotingClassifier

Visualizing the probabilistic predictions of a VotingClassifier

Univariate Feature Selection

Univariate Feature Selection

Pipeline ANOVA SVM

Pipeline ANOVA SVM

Model-based and sequential feature selection

Model-based and sequential feature selection

Imputing missing values with variants of IterativeImputer

Imputing missing values with variants of IterativeImputer

Imputing missing values before building an estimator

Imputing missing values before building an estimator

Common pitfalls in the interpretation of coefficients of linear models

Common pitfalls in the interpretation of coefficients of linear models

Partial Dependence and Individual Conditional Expectation Plots

Partial Dependence and Individual Conditional Expectation Plots

Scalable learning with polynomial kernel approximation

Scalable learning with polynomial kernel approximation

Comparing Linear Bayesian Regressors

Comparing Linear Bayesian Regressors

Lasso model selection via information criteria

Lasso model selection via information criteria

Lasso model selection: AIC-BIC / cross-validation

Lasso model selection: AIC-BIC / cross-validation

Regularization path of L1- Logistic Regression

Regularization path of L1- Logistic Regression

Poisson regression and non-normal loss

Poisson regression and non-normal loss

Polynomial and Spline interpolation

Polynomial and Spline interpolation

Robust linear estimator fitting

Robust linear estimator fitting

One-Class SVM versus One-Class SVM using Stochastic Gradient Descent

One-Class SVM versus One-Class SVM using Stochastic Gradient Descent

Tweedie regression on insurance claims

Tweedie regression on insurance claims

Manifold learning on handwritten digits: Locally Linear Embedding, Isomap…

Manifold learning on handwritten digits: Locally Linear Embedding, Isomap...

Comparing anomaly detection algorithms for outlier detection on toy datasets

Comparing anomaly detection algorithms for outlier detection on toy datasets

Visualizations with Display Objects

Visualizations with Display Objects

Displaying estimators and complex pipelines

Displaying estimators and complex pipelines

Evaluation of outlier detection estimators

Evaluation of outlier detection estimators

Advanced Plotting With Partial Dependence

Advanced Plotting With Partial Dependence

Displaying Pipelines

Displaying Pipelines

Introducing the set_output API

Introducing the set_output API

Post-tuning the decision threshold for cost-sensitive learning

Post-tuning the decision threshold for cost-sensitive learning

Detection error tradeoff (DET) curve

Detection error tradeoff (DET) curve

Precision-Recall

Precision-Recall

Post-hoc tuning the cut-off point of decision function

Post-hoc tuning the cut-off point of decision function

Approximate nearest neighbors in TSNE

Approximate nearest neighbors in TSNE

Dimensionality Reduction with Neighborhood Components Analysis

Dimensionality Reduction with Neighborhood Components Analysis

Varying regularization in Multi-layer Perceptron

Varying regularization in Multi-layer Perceptron

Feature discretization

Feature discretization

Importance of Feature Scaling

Importance of Feature Scaling

Comparing Target Encoder with Other Encoders

Comparing Target Encoder with Other Encoders

Target Encoder’s Internal Cross fitting

Target Encoder's Internal Cross fitting

Release Highlights for scikit-learn 0.22

Release Highlights for scikit-learn 0.22

Release Highlights for scikit-learn 0.23

Release Highlights for scikit-learn 0.23

Release Highlights for scikit-learn 0.24

Release Highlights for scikit-learn 0.24

Release Highlights for scikit-learn 1.0

Release Highlights for scikit-learn 1.0

Release Highlights for scikit-learn 1.1

Release Highlights for scikit-learn 1.1

Release Highlights for scikit-learn 1.2

Release Highlights for scikit-learn 1.2

Release Highlights for scikit-learn 1.7

Release Highlights for scikit-learn 1.7

Clustering text documents using k-means

Clustering text documents using k-means