holisticai.bias.mitigation.MLDebiaser#
- class holisticai.bias.mitigation.MLDebiaser(*args, **kargs)[source]#
MLDebiaser postprocessing [1] debias predictions w.r.t. the sensitive class in each demographic group. This procedure takes as input a vector y and solves the optimization problem subject to the statistical parity constraint. This bias mitigation can be used for classification (binary and multiclass).
Parameters
- gammafloat
The regularization parameter.
- epsfloat
The tolerance for the convergence of the optimization algorithm.
- etafloat
The step size for the optimization algorithm.
- sgd_stepsint
The number of steps for the stochastic gradient descent optimization.
- full_gradient_epochsint
The number of epochs for the full gradient optimization.
- batch_sizeint
The batch size for the optimization algorithm.
- max_iterint
The maximum number of iterations for the optimization algorithm.
- verbosebool
The verbosity of the optimization algorithm.
Examples
>>> from holisticai.bias.mitigation import MLDebiaser >>> mitigator = MLDebiaser() >>> mitigator.fit(y_proba, group_a, group_b) >>> test_data_transformed = mitigator.predict(y_proba, group_a, group_b)
References
- fit(y_proba: ndarray, group_a: ndarray, group_b: ndarray)[source]#
Compute parameters for calibrated equalized odds.
Description
Compute parameters for calibrated equalized odds algorithm.
Parameters
- y_predarray-like
Predicted vector (num_examples,).
- group_aarray-like
Group membership vector (binary)
- group_barray-like
Group membership vector (binary)
Returns
Self
- fit_transform(y_proba: ndarray, group_a: ndarray, group_b: ndarray)[source]#
Fit and transform
Description
Fit and transform
Parameters
- y_probaarray-like
Predicted vector (num_examples,).
- group_aarray-like
Group membership vector (binary)
- group_barray-like
Group membership vector (binary)
Returns
dictionnary with new predictions
- transform(y_proba: ndarray, group_a: ndarray, group_b: ndarray)[source]#
Apply transform function to predictions and likelihoods
Description
Use a fitted probability to change the output label and invert the likelihood
Parameters
- y_probaarray-like
Predicted probability matrix (nb_examples, nb_classes)
- group_aarray-like
Group membership vector (binary)
- group_barray-like
Group membership vector (binary)
- thresholdfloat
float value to discriminate between 0 and 1
Returns
- dict
A dictionnary with new predictions