make_pipeline#
- sklearn.pipeline.make_pipeline(*steps,memory=None,transform_input=None,verbose=False)[source]#
Construct a
Pipelinefrom the given estimators.This is a shorthand for the
Pipelineconstructor; 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 attribute
named_stepsorstepsto 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 to
fit(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 using
sklearn.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-learn
Pipelineobject.
See also
PipelineClass 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#
A demo of K-Means clustering on the handwritten digits data
Principal Component Regression vs Partial Least Squares Regression
Visualizing the probabilistic predictions of a VotingClassifier
Imputing missing values with variants of IterativeImputer
Imputing missing values before building an estimator
Common pitfalls in the interpretation of coefficients of linear models
Partial Dependence and Individual Conditional Expectation Plots
Scalable learning with polynomial kernel approximation
One-Class SVM versus One-Class SVM using Stochastic Gradient Descent
Manifold learning on handwritten digits: Locally Linear Embedding, Isomap…
Comparing anomaly detection algorithms for outlier detection on toy datasets
Post-tuning the decision threshold for cost-sensitive learning
Post-hoc tuning the cut-off point of decision function
Dimensionality Reduction with Neighborhood Components Analysis
