aif360.algorithms.inprocessing.ExponentiatedGradientReduction

class aif360.algorithms.inprocessing.ExponentiatedGradientReduction(estimator, constraints, eps=0.01, max_iter=50, nu=None, eta0=2.0, run_linprog_step=True, drop_prot_attr=True)[source]

Exponentiated gradient reduction for fair classification.

Exponentiated gradient reduction is an in-processing technique that reduces fair classification to a sequence of cost-sensitive classification problems, returning a randomized classifier with the lowest empirical error subject to fair classification constraints [1].

References

Parameters:
  • estimator – An estimator implementing methods fit(X, y, sample_weight) and predict(X), where X is the matrix of features, y is the vector of labels, and sample_weight is a vector of weights; labels y and predictions returned by predict(X) are either 0 or 1 – e.g. scikit-learn classifiers.

  • constraints (str or fairlearn.reductions.Moment) – If string, keyword denoting the fairlearn.reductions.Moment object defining the disparity constraints – e.g., “DemographicParity” or “EqualizedOdds”. For a full list of possible options see self.model.moments. Otherwise, provide the desired Moment object defining the disparity constraints.

  • eps – Allowed fairness constraint violation; the solution is guaranteed to have the error within 2*best_gap of the best error under constraint eps; the constraint violation is at most 2*(eps+best_gap).

  • T – Maximum number of iterations.

  • nu – Convergence threshold for the duality gap, corresponding to a conservative automatic setting based on the statistical uncertainty in measuring classification error.

  • eta_mul – Initial setting of the learning rate.

  • run_linprog_step – If True each step of exponentiated gradient is followed by the saddle point optimization over the convex hull of classifiers returned so far.

  • drop_prot_attr – Boolean flag indicating whether to drop protected attributes from training data.

Methods

fit

Learns randomized model with less bias

fit_predict

Train a model on the input and predict the labels.

fit_transform

Train a model on the input and transform the dataset accordingly.

predict

Obtain the predictions for the provided dataset using the randomized model learned.

transform

Return a new dataset generated by running this Transformer on the input.

__init__(estimator, constraints, eps=0.01, max_iter=50, nu=None, eta0=2.0, run_linprog_step=True, drop_prot_attr=True)[source]
Parameters:
  • estimator – An estimator implementing methods fit(X, y, sample_weight) and predict(X), where X is the matrix of features, y is the vector of labels, and sample_weight is a vector of weights; labels y and predictions returned by predict(X) are either 0 or 1 – e.g. scikit-learn classifiers.

  • constraints (str or fairlearn.reductions.Moment) – If string, keyword denoting the fairlearn.reductions.Moment object defining the disparity constraints – e.g., “DemographicParity” or “EqualizedOdds”. For a full list of possible options see self.model.moments. Otherwise, provide the desired Moment object defining the disparity constraints.

  • eps – Allowed fairness constraint violation; the solution is guaranteed to have the error within 2*best_gap of the best error under constraint eps; the constraint violation is at most 2*(eps+best_gap).

  • T – Maximum number of iterations.

  • nu – Convergence threshold for the duality gap, corresponding to a conservative automatic setting based on the statistical uncertainty in measuring classification error.

  • eta_mul – Initial setting of the learning rate.

  • run_linprog_step – If True each step of exponentiated gradient is followed by the saddle point optimization over the convex hull of classifiers returned so far.

  • drop_prot_attr – Boolean flag indicating whether to drop protected attributes from training data.

fit(dataset)[source]

Learns randomized model with less bias

Parameters:

dataset – (Binary label) Dataset containing true labels.

Returns:

ExponentiatedGradientReduction – Returns self.

predict(dataset)[source]

Obtain the predictions for the provided dataset using the randomized model learned.

Parameters:

dataset – (Binary label) Dataset containing labels that needs to be transformed.

Returns:

dataset – Transformed (Binary label) dataset.