chainladder.Pipeline

Contents

chainladder.Pipeline#

class chainladder.Pipeline(steps, *, memory=None, verbose=False)#

This is a near direct of copy the scikit-learn Pipeline class.

Sequentially apply 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 to None. Read more in the User Guide.

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: None, str or object with the joblib.Memory interface, optional

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.

Attributes
———-
named_steps: bunch object, a dictionary with attribute access

Read-only attribute to access any step parameter by user given name. Keys are step names and values are steps parameters.

Attributes:
classes_

The classes labels.

feature_names_in_

Names of features seen during first step fit method.

n_features_in_

Number of features seen during first step fit method.

named_steps

Access the steps by name.

Methods

decision_function(X)

Transform the data, and apply decision_function with the final estimator.

fit(X[, y, sample_weight])

Fit the model.

fit_predict(X[, y, sample_weight])

Transform the data, and apply fit_predict with the final estimator.

fit_transform(X[, y])

Fit the model and transform with the final estimator.

get_feature_names_out([input_features])

Get output feature names for transformation.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

inverse_transform(Xt)

Apply inverse_transform for each step in a reverse order.

predict(X[, sample_weight])

Transform the data, and apply predict with the final estimator.

predict_log_proba(X, **predict_log_proba_params)

Transform the data, and apply predict_log_proba with the final estimator.

predict_proba(X, **predict_proba_params)

Transform the data, and apply predict_proba with the final estimator.

score(X[, y, sample_weight])

Transform the data, and apply score with the final estimator.

score_samples(X)

Transform the data, and apply score_samples with the final estimator.

set_fit_request(*[, sample_weight])

Request metadata passed to the fit method.

set_output(*[, transform])

Set the output container when "transform" and "fit_transform" are called.

set_params(**kwargs)

Set the parameters of this estimator.

set_predict_request(*[, sample_weight])

Request metadata passed to the predict method.

set_score_request(*[, sample_weight])

Request metadata passed to the score method.

to_json()

Serializes triangle object to json format

to_pickle(path[, protocol])

Serializes triangle object to pickle.

transform(X)

Transform the data, and apply transform with the final estimator.