holisticai.bias.mitigation.CorrelationRemover#

class holisticai.bias.mitigation.CorrelationRemover(*args, **kargs)[source]#

CorrelationRemover applies a linear transformation to the non-sensitive feature columns in order to remove their correlation with the sensitive feature columns while retaining as much information as possible (as measured by the least-squares error).

Parameters

alphafloat, optional

parameter to control how much to filter, for alpha=1.0 we filter out all information while for alpha=0.0 we don’t apply any. Default is 1.

Notes

This method will change the original dataset by removing all correlation with sensitive values. Note that the lack of correlation does not imply anything about statistical dependence. Therefore, it is expected this to be most appropriate as a preprocessing step for (generalized) linear models.

Examples

>>> from holisticai.bias.mitigation import CorrelationRemover
>>> mitigator = CorrelationRemover()
>>> train_data_transformed = mitigator.fit_transform(train_data, group_a, group_b)
>>> test_data_transformed = mitigator.transform(test_data, group_a, group_b)
fit(X: Array, group_a: Array, group_b: Array)[source]#

Learn the projection required to make the dataset uncorrelated with groups (group_a and group_b).

Parameters

Xmatrix-like

Input data

group_aarray-like

Group membership vector (binary)

group_barray-like

Group membership vector (binary)

Returns

Self

fit_transform(X: Array, group_a: Array, group_b: Array)[source]#

Fit and transform

Parameters

Xmatrix-like

Input data

group_aarray-like

Group membership vector (binary)

group_barray-like

Group membership vector (binary)

Returns

Self

transform(X: Array, group_a: Array, group_b: Array)[source]#

Transform X by applying the correlation remover.

Parameters

Xmatrix-like

Input matrix

group_aarray-like

Group membership vector (binary)

group_barray-like

Group membership vector (binary)

Returns

np.ndarray