holisticai.bias.mitigation.Reweighing#

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

Reweighing preprocessing [1] weights the examples in each group-label combination to ensure fairness before classification.

Examples

>>> from holisticai.bias.mitigation import Reweighing
>>> mitigator = Reweighing()
>>> train_data_transformed = mitigator.fit_transform(train_data, group_a, group_b)
>>> test_data_transformed = mitigator.transform(test_data, group_a, group_b)

References

fit(y: ndarray, group_a: ndarray, group_b: ndarray, sample_weight: ndarray | None = None)[source]#

Fit the Reweighing model to the data. This method calculates the sample weights to ensure that the data is fair with respect to the specified sensitive groups before classification.

Parameters

yarray-like

Target vector

group_aarray-like

Group membership vector (binary)

group_barray-like

Group membership vector (binary)

sample_weightarray-like, optional

Samples weights vector. Default is None.

Returns

Self

fit_transform(X: ndarray, y: ndarray, group_a: ndarray, group_b: ndarray, sample_weight: ndarray | None = None)[source]#

Fit the Reweighing model to the data. This method calculates the sample weights to ensure that the data is fair with respect to the specified sensitive groups before classification. The transform function returns the same object inputed.

Parameters

Xmatrix-like

Input matrix

yarray-like

Target vector

group_aarray-like

Group membership vector (binary)

group_barray-like

Group membership vector (binary)

sample_weightarray-like, optional

Samples weights vector. Default is None.

Returns

self

transform(X: ndarray)[source]#

passthrough