holisticai.bias.mitigation.FairKMedianClustering#

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

Fair K-Median Clustering

Fair K-median clustering [1] inprocessing bias mitigation is an approximation algorithm for group representative k-median clustering. The fair k-median method addresses fairness in clustering by ensuring equitable representation across different demographic groups. It involves bundling, matching and sampling. This method aims to minimize bias and provide fair clustering solutions.

Parameters

n_clustersint

number of clusters.

max_iterint

Max number of iteration for LS or epochs for GA.

strategystr

Minimization method used. Available: - LS (Local Search). - GA (Genetic Algorithm)

verboseint

if > 0 , print progress information.

seedint

random seed.

Examples

>>> from holisticai.bias.mitigation import FairKMedianClustering
>>> mitigator = FairKMedianClustering(**params)
>>> mitigator.fit(train_data, group_a, group_b)
>>> test_data_transformed = mitigator.predict(test_data, group_a, group_b)

References

fit(X, group_a, group_b)[source]#

Fit model using Fair K-median Clustering.

Parameters

Xmatrix-like

Input matrix

group_aarray-like

Group membership vector (binary)

group_barray-like

Group membership vector (binary)

Returns

Self

set_fit_request(*, group_a: bool | None | str = '$UNCHANGED$', group_b: bool | None | str = '$UNCHANGED$') FairKMedianClustering#

Request metadata passed to the fit 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 fit 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 fit.

  • 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

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

Metadata routing for group_a parameter in fit.

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

Metadata routing for group_b parameter in fit.

Returns

selfobject

The updated object.