holisticai.bias.mitigation.MCMF#
- class holisticai.bias.mitigation.MCMF(*args, **kargs)[source]#
Minimal Cluster Modification for Fairnes (MCMF) [1] is focused on the minimal change it so that the clustering is still of good quality and fairer.
Parameters
- metricstr
Measure function used in the objective function. The metrics available are: [“constant”, “L1”, “L2”]
- solverstr
Algorithm name used to solve the standard form problem. Solver supported must depend of your scipy package version. for scipy 1.9.0 the solvers available are: [“highs”, “highs-ds”, “highs-ipm”]
- group_modestr
Set what groups will be fitted: [‘a’, ‘b’, ‘ab’]
- verboseint
If > 0 , then print logs.
Examples
>>> from holisticai.bias.mitigation import MCMF >>> mitigator = MCMF(**params) >>> mitigator.fit_transform(X, y_pred, group_a, group_b) >>> test_data_transformed = mitigator.transform(X, y_pred, group_a, group_b)
References
- fit_transform(X: np.ndarray, y_pred: np.ndarray, group_a: np.ndarray, group_b: np.ndarray, centroids: np.ndarray) dict[str, np.ndarray][source]#
Fit and transform the MCMF algorithm.
Description
Fit the MCMF algorithm and transform the predicted vector.
Parameters
- Xmatrix-like
Input matrix (nb_examples, nb_features)
- y_predarray-like
Predicted vector (nb_examples,)
- group_aarray-like
Group membership vector (binary)
- group_barray-like
Group membership vector (binary)
- centroidsndarray
Centroids array
Returns
- dict
A dictionary with new predictions
- transform(X: np.ndarray, y_pred: np.ndarray, group_a: np.ndarray, group_b: np.ndarray, centroids: np.ndarray) dict[str, np.ndarray][source]#
Modify y_pred using MCMF algorithm.
Description
Build parameters for the objetive function and call the solver to find the algorithm parameters.
Parameters
- Xmatrix-like
Input matrix (nb_examples, nb_features)
- y_predarray-like
Predicted vector (nb_examples,)
- group_aarray-like
Group membership vector (binary)
- group_barray-like
Group membership vector (binary)
- centroidsndarray
Centroids array
Returns
- dict
A dictionary with new predictions