holisticai.bias.mitigation.FairScoreClassifier#
- class holisticai.bias.mitigation.FairScoreClassifier(*args, **kargs)[source]#
Fair Score Classifier [1] generates a classification model that integrates fairness constraints for multiclass classification. This algorithm returns a matrix of lambda coefficients that scores a given input vector. The higher the score, the higher the probability of the input vector to be classified as the majority class.
Parameters
- objectivesdict
The weighted objectives list to be optimized.
- constraintsdict
The constraints list to be used in the optimization. The keys are the constraints names and the values are the bounds.
- lambda_boundint
Lower and upper bound for the scoring system cofficients.
- time_limitint
The time limit for the optimization algorithm.
- verboseint
If >0, will show progress percentage.
Examples
>>> from holisticai.bias.mitigation import FairScoreClassifier >>> mitigator = FairScoreClassifier(**params) >>> mitigator.fit(train_data, y, group_a, group_b) >>> test_data_transformed = mitigator.predict(test_data, group_a, group_b)
References
- fit(X, y, group_a, group_b)[source]#
Fit model using Grid Search Algorithm.
Parameters
- Xmatrix-like
input matrix
- ynumpy array
target vector
- protected_groupslist
The sensitive groups.
- protected_labelslist
The senstive labels.
- sensitive_featuresnumpy array
Matrix where each columns is a sensitive feature e.g. [col_1=group_a, col_2=group_b]
Returns
self
- predict(X, group_a, group_b)[source]#
Predict the target vector.
Parameters
- Xmatrix-like
input matrix
- group_anumpy array
binary mask vector
- group_bnumpy array
binary mask vector
Returns
numpy array
- set_fit_request(*, group_a: bool | None | str = '$UNCHANGED$', group_b: bool | None | str = '$UNCHANGED$') FairScoreClassifier#
Request metadata passed to the
fitmethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.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_aparameter infit.- group_bstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
group_bparameter infit.
Returns
- selfobject
The updated object.
- set_predict_request(*, group_a: bool | None | str = '$UNCHANGED$', group_b: bool | None | str = '$UNCHANGED$') FairScoreClassifier#
Request metadata passed to the
predictmethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.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_aparameter inpredict.- group_bstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
group_bparameter inpredict.
Returns
- selfobject
The updated object.