9.20.1. sklearn.pipeline.Pipeline¶
- class sklearn.pipeline.Pipeline(steps)¶
Pipeline of transforms with a final estimator
Sequentialy apply a list of transforms and a final estimator. Intermediate steps of the pipeline must be ‘transforms’, that is that they must implements fit & transform methods The final estimator need only implements fit.
The purpose of the pipeline is to assemble several steps that can be cross-validated together while setting different parameters. For this, it enables to setting parameters of the various steps using their names and the parameter name separated by a ‘__’, as in the example below.
Attributes
Methods
fit: Fit all the transforms one after the other and transform the data, then fit the transformed data using the final estimator fit_transform: Fit all the transforms one after the other and transform the data, then use fit_transform on transformed data using the final estimator. Valid only if the final estimator implements fit_transform. predict: Applies transforms to the data, and the predict method of the final estimator. Valid only if the final estimator implements predict. transform: Applies transforms to the data, and the transform method of the final estimator. Valid only if the final estimator implements transform. score: Applies transforms to the data, and the score method of the final estimator. Valid only if the final estimator implements score. - __init__(steps)¶
Parameters : steps: list :
List of (name, transform) object (implementing fit/transform) that are chained, in the order in which they are chained, with the last object an estimator.
- set_params(**params)¶
Set the parameters of the estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The former have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.
Returns : self :