skclean.pipeline.Pipeline

class skclean.pipeline.Pipeline(**kwargs)

Sequentially applies a list of transforms and a final estimator. Intermediate steps of the pipeline must be ‘transforms’, that is, they must implement fit and transform methods. The final estimator only needs to implement fit. The transformers in the pipeline can be cached using memory argument.

The purpose of the pipeline is to assemble several steps that can be cross-validated together while setting different parameters. For this, it enables setting parameters of the various steps using their names and the parameter name separated by a ‘__’, as in the example below. A step’s estimator may be replaced entirely by setting the parameter with its name to another estimator, or a transformer removed by setting it to ‘passthrough’ or None.

See link for details.

Parameters
  • steps (list) – List of (name, transform) tuples (implementing fit/transform) that are chained, in the order in which they are chained, with the last object an estimator.

  • memory (str or object with the joblib.Memory interface, default=None) – Used to cache the fitted transformers of the pipeline. By default, no caching is performed. If a string is given, it is the path to the caching directory. Enabling caching triggers a clone of the transformers before fitting. Therefore, the transformer instance given to the pipeline cannot be inspected directly. Use the attribute named_steps or steps to inspect estimators within the pipeline. Caching the transformers is advantageous when fitting is time consuming.

  • verbose (bool, default=False) – If True, the time elapsed while fitting each step will be printed as it is completed

Methods

__init__(steps, *[, memory, verbose])

Initialize self.

decision_function(X)

Apply transforms, and decision_function of the final estimator

fit(X[, y])

Fit the model.

fit_predict(X[, y])

Apply fit_predict of last step in pipeline after transforms.

fit_transform(X[, y])

Fit the model and transform with the final estimator.

get_params([deep])

Get parameters for this estimator.

predict(X, **predict_params)

Apply transforms to the data, and predict with the final estimator

predict_log_proba(X)

Apply transforms, and predict_log_proba of the final estimator

predict_proba(X)

Apply transforms, and predict_proba of the final estimator

score(X[, y, sample_weight])

Apply transforms, and score with the final estimator

score_samples(X)

Apply transforms, and score_samples of the final estimator.

set_params(**kwargs)

Set the parameters of this estimator.

Attributes

classes_

inverse_transform

Apply inverse transformations in reverse order

n_features_in_

named_steps

transform

Apply transforms, and transform with the final estimator