holisticai.pipeline.Pipeline#

class holisticai.pipeline.Pipeline(steps, *, memory=None, verbose=False)[source]#

Holistic AI Pipeline

Description

Holisticai pipeline wrap the sklearn pipeline to support unconventional transformers. Unconventional transformers (u-transformers) are transformers that doesn’t follow the typically sklearn workflow. For example, Bias Mitigator needs update inputs, outputs, and other parameters during the fit and transform process. The current version of this pipeline supports only binary classification.

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

Fit the model.

Fit all the transformers/u-transformers one after the other and transform the data and parameters. Then, fit the transformed data using the final estimator. Finally, fit the u-transformers for postprocessing.

Parameters

Xiterable

Training data. Must fulfill input requirements of first step of the pipeline.

yiterable, default=None

Training targets. Must fulfill label requirements for all steps of the pipeline.

**fit_paramsdict of string -> object

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.

Returns

selfobject

Pipeline with fitted steps.

predict_proba(X, **predict_proba_params)[source]#

Update avaiable conditions for predict_proba

predict_score(X, **predict_score_params)[source]#

Return probability vector

Description

Transform the data, and the postprocessor u-transformer compute the predictions for that model. Only available with postprocessors bias mitigator.

Parameters

Xiterable

Data to predict on. Must fulfill input requirements of first step of the pipeline.

Returns

np.ndarray

probability value for each example

predictions(X, **params)[source]#

Post-processor prediction

Description

Transform the data, and the postprocessor u-transformer compute the predictions for that model. If the pipeline doesn’t have postprocessors, sklearn pipeline functions are used for prediction.

Parameters

Xiterable

Data to predict on. Must fulfill input requirements of first step of the pipeline.

**paramsdict of string -> object

Parameters to the predict called at the end of all transformations in the pipeline. 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.

Added in version 0.20.

Returns

dict

dictionary with postprocessor outputs

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') Pipeline#

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters

sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in score.

Returns

selfobject

The updated object.