aif360.algorithms.Transformer

class aif360.algorithms.Transformer(**kwargs)[source]

Abstract base class for transformers.

Transformers are an abstraction for any process which acts on a Dataset and returns a new, modified Dataset. This definition encompasses pre-processing, in-processing, and post-processing algorithms.

Initialize a Transformer object.

Algorithm-specific configuration parameters should be passed here.

Methods

fit

Train a model on the input.

fit_predict

Train a model on the input and predict the labels.

fit_transform

Train a model on the input and transform the dataset accordingly.

predict

Return a new dataset with labels predicted by running this Transformer on the input.

transform

Return a new dataset generated by running this Transformer on the input.

abstract __init__(**kwargs)[source]

Initialize a Transformer object.

Algorithm-specific configuration parameters should be passed here.

fit(dataset)[source]

Train a model on the input.

Parameters:

dataset (Dataset) – Input dataset.

Returns:

Transformer – Returns self.

fit_predict(dataset)[source]

Train a model on the input and predict the labels.

Equivalent to calling fit(dataset) followed by predict(dataset).

Parameters:

dataset (Dataset) – Input dataset.

Returns:

Dataset – Output dataset. metadata should reflect the details of this transformation.

fit_transform(dataset)[source]

Train a model on the input and transform the dataset accordingly.

Equivalent to calling fit(dataset) followed by transform(dataset).

Parameters:

dataset (Dataset) – Input dataset.

Returns:

Dataset – Output dataset. metadata should reflect the details of this transformation.

predict(dataset)[source]

Return a new dataset with labels predicted by running this Transformer on the input.

Parameters:

dataset (Dataset) – Input dataset.

Returns:

Dataset – Output dataset. metadata should reflect the details of this transformation.

transform(dataset)[source]

Return a new dataset generated by running this Transformer on the input.

This function could return different dataset.features, dataset.labels, or both.

Parameters:

dataset (Dataset) – Input dataset.

Returns:

Dataset – Output dataset. metadata should reflect the details of this transformation.