elphick.mass_composition.utils.sklearn.PandasPipeline

class elphick.mass_composition.utils.sklearn.PandasPipeline(steps, memory=None, verbose=False)[source]
__init__(steps, memory=None, verbose=False)[source]

Methods

__init__(steps[, memory, verbose])

decision_function(X, **params)

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

fit(X[, y])

Fit the model.

fit_predict(X[, y])

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

fit_transform(X[, y])

Fit the model and transform with the final estimator.

from_pipeline(pipeline)

get_feature_names_out()

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, **params)

Apply inverse_transform for each step in a reverse order.

predict(X)

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

predict_log_proba(X, **params)

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

predict_proba(X, **params)

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

score(X, y)

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_output(*[, transform])

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

set_params(**kwargs)

Set the parameters of this estimator.

set_score_request(*[, sample_weight])

Request metadata passed to the score method.

transform(X, **kwargs)

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

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.

fit(X, y=None, **fit_params)[source]

Fit the model.

Fit all the transformers one after the other and sequentially transform the data. Finally, fit the transformed data using the final estimator.

Parameters:
  • X (iterable) – Training data. Must fulfill input requirements of first step of the pipeline.

  • y (iterable, default=None) – Training targets. Must fulfill label requirements for all steps of the pipeline.

  • **params (dict of str -> object) –

    • If enable_metadata_routing=False (default):

      Parameters passed to the fit method of each step, where each parameter name is prefixed such that parameter p for step s has key s__p.

    • If enable_metadata_routing=True:

      Parameters requested and accepted by steps. Each step must have requested certain metadata for these parameters to be forwarded to them.

    Changed in version 1.4: Parameters are now passed to the transform method of the intermediate steps as well, if requested, and if enable_metadata_routing=True is set via set_config().

    See Metadata Routing User Guide for more details.

Returns:

self – Pipeline with fitted steps.

Return type:

object

get_feature_names_out()[source]

Get output feature names for transformation.

Transform input features using the pipeline.

Parameters:

input_features (array-like of str or None, default=None) – Input features.

Returns:

feature_names_out – Transformed feature names.

Return type:

ndarray of str objects

predict(X)[source]

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

Call transform of each transformer in the pipeline. The transformed data are finally passed to the final estimator that calls predict method. Only valid if the final estimator implements predict.

Parameters:
  • X (iterable) – Data to predict on. Must fulfill input requirements of first step of the pipeline.

  • **params (dict of str -> object) –

    • If enable_metadata_routing=False (default):

      Parameters to the predict called at the end of all transformations in the pipeline.

    • If enable_metadata_routing=True:

      Parameters requested and accepted by steps. Each step must have requested certain metadata for these parameters to be forwarded to them.

    New in version 0.20.

    Changed in version 1.4: Parameters are now passed to the transform method of the intermediate steps as well, if requested, and if enable_metadata_routing=True is set via set_config().

    See Metadata Routing User Guide for more details.

    Note that while this may be used to return uncertainties from some models with return_std or return_cov, uncertainties that are generated by the transformations in the pipeline are not propagated to the final estimator.

Returns:

y_pred – Result of calling predict on the final estimator.

Return type:

ndarray

score(X, y)[source]

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

Call transform of each transformer in the pipeline. The transformed data are finally passed to the final estimator that calls score method. Only valid if the final estimator implements score.

Parameters:
  • X (iterable) – Data to predict on. Must fulfill input requirements of first step of the pipeline.

  • y (iterable, default=None) – Targets used for scoring. Must fulfill label requirements for all steps of the pipeline.

  • sample_weight (array-like, default=None) – If not None, this argument is passed as sample_weight keyword argument to the score method of the final estimator.

  • **params (dict of str -> object) –

    Parameters requested and accepted by steps. Each step must have requested certain metadata for these parameters to be forwarded to them.

    New in version 1.4: Only available if enable_metadata_routing=True. See Metadata Routing User Guide for more details.

Returns:

score – Result of calling score on the final estimator.

Return type:

float

transform(X, **kwargs)[source]

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

Call transform of each transformer in the pipeline. The transformed data are finally passed to the final estimator that calls transform method. Only valid if the final estimator implements transform.

This also works where final estimator is None in which case all prior transformations are applied.

Parameters:
  • X (iterable) – Data to transform. Must fulfill input requirements of first step of the pipeline.

  • **params (dict of str -> object) –

    Parameters requested and accepted by steps. Each step must have requested certain metadata for these parameters to be forwarded to them.

    New in version 1.4: Only available if enable_metadata_routing=True. See Metadata Routing User Guide for more details.

Returns:

Xt – Transformed data.

Return type:

ndarray of shape (n_samples, n_transformed_features)