fairlearn.reductions.ErrorRate#

class fairlearn.reductions.ErrorRate(*, costs=None)[source]#

Misclassification error as a moment.

A classifier \(h(X)\) has the misclassification error equal to

\[P[h(X) \ne Y]\]

It is also possible to specify costs for false positives and false negatives. The error then evaluates to

\[c_{FP} P[h(X)=1, Y=0] + c_{FN} P[h(X)=0, Y=1]\]

where \(c_{FP}\) and \(c_{FN}\) are the costs of false positive and false negative errors respectively. The default misclassification error corresponds to \(c_{FP}=c_{FN}=1.0\).

Read more in the User Guide.

Parameters:
costsdict

Dictionary with keys 'fp' and 'fn' containing the costs of false positives and false negatives. If none are provided costs of 1.0 are assumed.

bound()[source]#

Return vector of fairness bound constraint the length of gamma.

Return type:

Series

default_objective()[source]#

Return the default objective for the moment.

Return type:

Moment

gamma(predictor)[source]#

Calculate a vector of moments.

When ErrorRate() is used as a constraint, then gamma[j]≤0 for all j is used as the set of constraints. When ErrorRate() is used as an objective, then gamma[0] is used as the objective.

Return type:

Series

Parameters:
predictorfunc

bound function returning predictions

Returns:
errorpandas.Series

gamma value for the predictor

load_data(X, y, *, sensitive_features, control_features=None)[source]#

Load the specified data into the object.

Return type:

None

Parameters:
Xarray of shape (n_samples, n_features)

The feature array

yarray-like of shape (n_samples,)

The label vector

sensitive_featuresarray-like of shape (n_samples, n_sensitive_features)

The sensitive feature vector

project_lambda(lambda_vec)[source]#

Return the lambda values.

Return type:

Series

signed_weights(lambda_vec=None)[source]#

Return the signed weights.

Return type:

Series

property index: Index#

Return the index listing the constraints.

property total_samples: int#

Return the number of samples in the data.