Package: autogluon.fair
Fairness for AutoMLAutogluon.fair provides additional tools to enforce a wide-range of fairness definitions and to customize binary classifier behavior.InstructionsInstall autogluon (seehttps://auto.gluon.ai/stable/index.html#installation)Download the source of autogluon.fair and in the source directory run:
python3 -m pip install -e .Now run theExample Notebookor try some of the example below.Example usage# Load and train a baseline classifier

from autogluon.tabular import TabularDataset, TabularPredictor
from autogluon.fair import FairPredictor
from autogluon.fair.utils import group_metrics as gm
train_data = TabularDataset('https://autogluon.s3.amazonaws.com/datasets/Inc/train.csv')
test_data = TabularDataset('https://autogluon.s3.amazonaws.com/datasets/Inc/test.csv')
predictor = TabularPredictor(label='class').fit(train_data=train_data)

# Modify predictor to enforce fairness over the train_data with respect to groups given by the column 'sex'
fpredictor = FairPredictor(predictor,train_data,'sex')
# Maximize accuracy while enforcing that the demographic parity (the difference in positive decision rates between men and women is at most 0.02)
fpredictor.fit(gm.accuracy,gm.demographic_parity,0.02)

# Evaluate on test data
fpredictor.predict(test_data)

# Evaluate a range of performance measures, and compare against original classifier on test data
fpredictor.evaluate(test_data, verbose= True)originalupdatedAccuracy0.8764460.853926Balanced Accuracy0.7967080.757129F1 score0.7124140.650502MCC0.6405030.568616Precision0.7956360.752408Recall0.6449530.572908roc_auc0.9315730.827535# Evaluate against a range of standard fairness definitions and compare against original classifier on test data
fpredictor.evaluate_fairness(test_data, verbose= True)originalupdatedClass Imbalance0.1959130.195913Demographic Parity0.1666690.00744171Disparate Impact0.3291820.959369Maximal Group Difference in Accuracy0.09367570.0684973Maximal Group Difference in Recall0.05904320.326703Maximal Group Difference in Conditional Acceptance Rate0.09177081.04471Maximal Group Difference in Acceptance Rate0.01746750.347018Maximal Group Difference in Specificity0.05188690.0594707Maximal Group Difference in Conditional Rejectance Rate0.04508070.229982Maximal Group Difference in Rejection Rate0.09227940.157476Treatment Equality0.06535385.07559Generalized Entropy0.06662040.080265# Evaluate a range of performance measures per group, and compare against original classifier on test data
fpredictor.evaluate_groups(test_data, verbose= True, return_original=True)AccuracyBalanced AccuracyF1 scoreMCCPrecisionRecallroc_aucPositive CountNegative CountPositive Label RatePositive Prediction Rate('original', 'Overall')0.8764460.7967080.7124140.6405030.7956360.6449530.931573231874510.2372810.192343('original', ' Female')0.9385830.7874030.6752410.6492420.7806690.5949010.94925135329360.1073270.0817878('original', ' Male')0.8449070.7909810.7188810.6190520.7981370.6539440.91321196545150.3032410.248457('original', 'Maximum difference')0.09367570.003578130.043640.030190.01746750.05904320.0360405161215790.1959130.166669('updated', 'Overall')0.8539260.7571290.6505020.5686160.7524080.5729080.827535231874510.2372810.180674('updated', ' Female')0.8993620.8775860.6444680.6141610.5190310.8498580.94925135329360.1073270.175737('updated', ' Male')0.8308640.743970.6522840.5798290.8660490.5231550.91321196545150.3032410.183179('updated', 'Maximum difference')0.06849730.1336160.007815950.03433270.3470180.3267030.0360405161215790.1959130.00744171OverviewAutogluon.fair is a postprocessing approach for enforcing fairness, with support for a wide range of performance metrics and fairness criteria, and support for inferred attributes, i.e. it does not require access to protected attributes at test time.
Under the hood, FairPredictor works by adjusting the decision boundary for each group individually. Where groups are not available, it makes use of inferred group membership to adjust decision boundaries.The key idea underlying this toolkit is that for a wide range of use cases, the most suitable classifier should do more than maximize some form of accuracy.
We offer a general toolkit that allows different measures to be optimized and additional constraints to be imposed by tuning the behavior of a binary predictor on validation data.For example, classifiers can be tuned to maximize performance for a wide range of metrics such as:AccuracyBalanced AccuracyF1 scoreMCCCustom utility functionsWhile also approximately satisfying a wide range of group constraints such as:Demographic Parity (The idea that positive decisions should occur at the same rates for all protected groups, for example for men at the same rate as for women)Equal Opportunity (The recall should be the same for all protected groups)Minimum Recall Constraints (The recall should be above a particular level for all groups)Minimum Precision Constraints (The precision should be above a particular level for all groups)Custom Fairness MetricsThe full set of constraints and objectives can be seen in the list of measures at the bottom of the document.Why Another Fairness Library?Fundamentally, most existing fairness methods are not appropriate for ensemble methods like AutoGluon.
Under the hood, autogluon makes use of many different types of classifiers trained on random subsets of the data, and it's inherent complexity makes fairness methods that iteratively retrain classifiers punitively slow. The use of random subsets makes AutoGluon robust to small amounts of mislabeled data, but also means that methods that iteratively make small changes to the training data to enforce fairness can have unpredictable behavior. At same time, the many different types of sub-classifiers used mean that any method inprocessing method that requires the alteration of every method used to train a sub-classifier is not feasible.That said, we make several design decisions which we believe make for a better experience for data scientists:Fine-grained control of behaviorWide Choice of performance measureUnlike other approaches to fairness, FairPredictor allows the optimization of arbitrary performance measures such as F1 or MCC, subject to fairness constraints. This can substantially improve the fairness/performance trade-off with, for example, F1 scores being 3-4% higher when directly optimized for rather than accuracy.Wide Choice of Fairness MeasuresRather than offering a range of different fairness methods that enforce a small number of fairness definitions through a variety of different methods, we offer one method that can enforce a much wider range of fairness definitions out of the box, alongside support for custom fairness definitions.Of the set of metrics discussed inVerma and Rubin, and the metrics measured bySagemaker Clarify, out of the box FairPredictor offers the ability to both measure and enforce 7 of the 8 metrics used to evaluate classifier decision measured in Verma and Rubin, and 11 of the 13 measures used in Clarify.Direct Remedy of HarmsSee summaryarticleon the problems this addresses. More details are in thepaper.An Ipython notebook generating many of the figures in the paper can be found here:Levelling up notebookMany fairness measures can be understood as identifying a harm, and then equalizing this harm across the population as a whole. For example, the use demographic parity of identifies people as being harmed by a low selection rate, which is then set to be the same for all groups, while equal opportunity identifies people as being harmed by low recall, and balances this harm across all groups. However, these fairness formulations often explicitlyAs an alternative to equalizing the harm across the population, we allow data scientists to specify minimum rates of e.g., recall, precision, or selection rate for every group, with one line of code. E.g.fpredictor.fit(gm.accuracy, gm.precision.min, 0.5)finds a classifier that maximizes accuracy while having a precision of at least 0.5 for every group.These constraints have wider uses outside of fairness. For example, a classifier can be trained to identify common defects across multiple factory lines, and its behavior can be altered to enforce a recall of 90% of all defects for each line (at a cost of increased false positives).fpredictor.fit(gm.accuracy, gm.recall.min, 0.9)Support for Utility based approachesWe provide support for the utility based approach set out inFairness On The Ground: Applying Algorithmic Fairness Approaches To Production Systems, whereby different thresholds can be selected per group to optimize a utility-based objective.Utility functions can be defined in one line.For example, if we have a situation where an ML system identifies potential problems that require intervening, it might be that every intervention has a cost of 1, regardless of if it was needed, but a missed intervention that was needed has a cost of 5. Finally, not making an intervention when one was not needed has a cost of 0. This can be written as:my_utility=gm.Utility([1, 1, 5, 0], 'Testing Costs')and optimized alongside fairness or performance constraints. For example,fpredictor.fit(my_utility)optimizes the utility, whilefpredictor.fit(my_utility, gm.accuracy, 0.5)optimizes the utility subject to the requirement that the classifier accuracy can not drop below 0.5.Support for user-specified performance and fairness measuresAs well as providing support for enforcing a wide range of performance and fairness measures, we allow users to define their own metrics and fairness measures.For example, a custom implementation of recall can be defined as:my_recall = gm.GroupMetric(lambda TP, FP, FN, TN: (TP) / (TP + FN), 'Recall')and then the maximum difference in recall between groups (corresponding to the fairness definition of Equal Opportunity) is provided by callingmy_recall.diff, and the minimum recall over any group (which can be used to ensure that the recall is above a particular value for every group) is given bymy_recall.min.Altering BehaviorThe behavior of classifiers can be altered through the fit function.
Given a pretrained binary predictor, we define a fair classifier that will allow us to alter the existing behavior on a validation dataset, by using a labeled attribute 'sex'.fpredictor = FairPredictor(predictor,  validation_data, 'sex')the fit function takes three arguments that describe an objective such as accuracy or F1 that should be optimized, and a constraint such as the demographic parity violation should be below 2%.This takes the form:fpredictor.fit(gm.f1, gm.demographic_parity, 0.02)The constraint and objective can be swapped so the code:fpredictor.fit(gm.demographic_parity, gm.f1, 0.75)will find the method with the lowest demographic parity violation such that F1 is above 0.75.
If, for example, you wish to optimize F1 without any additional constraints, you can just call:fpredictor.fit(gm.f1)Note that the default behavior (we should minimize the demographic parity violation, but maximize F1) is inferred from standard usage but can be overwritten by setting the optional parametersgreater_is_better_objandgreater_is_better_consttoTrueorFalse.Where constraints cannot be satisfied, for example, if we require that the F1 score must be above 1.1,fitreturns the solution closest to satisfying it.Measuring BehaviorA key challenge in deciding how to alter the behavior of classifiers is that these decisions have knock-on effects elsewhere. For example, increasing the precision of classifiers, will often decrease their recall and vice versa.In the same way, many fairness definitions may be at odds with one another, and increasing the fairness with respect to one definition can decrease it with respect to other definitions.As such, we offer a range of methods for evaluating the performance of classifiers.fpredictor.evaluate(data (optional), groups (optional), dictionary_of_methods (optional), verbose=False)By default, this method reports the standard binary evaluation criteria of autogluon for both the original and updated predictor, over the data used by fit. The behavior can be altered by providing either alternate data or a new dictionary of methods. Where groups are not provided, it will use the same groups as passed tofit, but this can be altered. If verbose is set to true, the table contains the long names of methods, otherwise it reports the dictionary keys.fpredictor.evaluate_fairness(data (optional), groups (optional), dictionary_of_methods (optional), verbose=False)By default, this method reports the standard fairness metrics of SageMaker Clarify for both the original and updated predictor, over the data used by fit. The behavior can be altered by providing either alternate data or a new dictionary of methods. Where groups is not provided, it will use the same groups as passed tofit, but this can be altered. If verbose is set to true, the table contains the long names of methods, otherwise it reports the dictionary keys.fpredictor.evaluate_groups(data (optional), groups (optional), dictionary_of_methods (optional), return_original=False, verbose=False)By default, this method reports, per group, the standard binary evaluation criteria of autogluon for both the updated predictor only, over the data used by fit. The behavior can be altered by providing either alternate data or a new dictionary of methods. Where groups is not provided, it will use the same groups as passed tofit, but this can be altered. If you wish to also see the per group performance of the original classifier, usereturn_original=Trueto receive a dict containing the per_group performance of the original and updated classifier. If verbose is set to true, the table contains the long names of methods, otherwise it reports the dictionary keys.Fairness using Inferred AttributesIn many cases, the attribute you wish to be fair with respect to such assexmay not be available at test time. In this case you can make use of inferred attributes predicted by another classifier. This can be done by defining the fair predictor in the following way.fpredictor = fair.FairPredictor(predictor,  data, 'sex', inferred_groups=attribute_pred)whereattribute_predis another autogluon predictor trained to predict the attribute, such assexyou wish to infer.
Thenfpredictorcan be used in same way described above.Note that the labeled attribute is used to evaluate fairness, and the use of the inferred attributes are tuned to optimize fairness with respect to the labeled attributes. This means that even if the inferred attributes are not that accurate, they can be still used to enforce fairness, albeit with a drop in performance.To make it easier to use inferred attributes, we provide a helper function:predictor, attribute_pred = fair.learners.inferred_attribute_builder(train_data, 'class', 'sex')This allows for the easy training of two tabular classifiers, one calledpredictorto predict the target labelclasswithout using the attributesexand one calledattribute_predto predictsexwithout using the the target label.Fairness on COMPAS using Inferred AttributesWe demonstrate how to enforce a wide range of fairness definitions on the COMPAS dataset. This dataset records paroles caught violating the terms of parole. As it measures who was caught, it is strongly influenced by policing and environmental biases, and should not be confused with a measurement of who actually violated their terms of parole. Seethis paperfor a discussion of its limitations and caveats.
We use it because it is a standard fairness dataset that captures such strong differences in outcome between people identified as African-American and everyone else, that classifiers trained on this dataset violate most definitions of fairness.As many of the ethnic groups are too small for reliable statistical estimation, we only consider differences is in outcomes between African-Americans vs. everyone else (labeled as other).
We load and preprocess the COMPAS dataset, splitting it into three roughly equal partitions of train, validation, and test:import pandas as pd
import   numpy   as   np
from autogluon.fair import FairPredictor, inferred_attribute_builder
from autogluon.fair.utils import group_metrics as gm
all_data = pd.read_csv('https://github.com/propublica/compas-analysis/raw/master/compas-scores-two-years.csv')
condensed_data=all_data[['sex','race','age', 'juv_fel_count', 'juv_misd_count', 'juv_other_count', 'priors_count', 'age_cat', 'c_charge_degree','two_year_recid']].copy()
condensed_data.replace({'Caucasian':'Other', 'Hispanic':'Other', 'Native American':'Other', 'Asian':'Other'},inplace=True)
train=condensed_data.sample(frac=0.3, random_state=0)
val_and_test=condensed_data.drop(train.index)
val=val_and_test.sample(frac=0.5, random_state=0)
test=val_and_test.drop(val.index)To enforce fairness constraints without access to protected attributes at test time, we train two classifiers to infer the 2-year recidivism rate, and ethnicity.predictor2, protected = inferred_attribute_builder(train, 'two_year_recid', 'race')From these a single predictor that maximizes accuracy while reducing the demographic parity violation to less than 2.5% can be trained by running:fpredictor=FairPredictor(predictor2, val, 'race', protected)
fpredictor.fit(gm.accuracy, gm.demographic_parity, 0.025)However, instead we will show how a family of fairness measures can be individually optimized. First, we consider the measures of Sagemaker Clarify that we support. The following code plots a table showing the change in accuracy and the fairness measure on a held-out test set as we decrease the fairness measure to less than 0.025 (on validation) for all measures except for disparate impact which we raise to above 0.975.
We define a helper function for evaluation:def evaluate(fpredictor,use_metrics):
    "Print a table showing the accuracy drop that comes with enforcing fairness"
    extra_metrics= {**use_metrics, 'accuracy':gm.accuracy}
    collect=pd.DataFrame(columns=['Measure (original)', 'Measure (updated)', 'Accuracy (original)', 'Accuracy (updated)'])
    for d in use_metrics.items():
        if d[1].greater_is_better is False:
            fpredictor.fit(gm.accuracy,d[1],0.025)
        else:
            fpredictor.fit(gm.accuracy,d[1],1-0.025)
        tmp=fpredictor.evaluate_fairness(test,metrics=extra_metrics)
        collect.loc[d[1].name]=np.concatenate((np.asarray(tmp.loc[d[0]]),np.asarray(tmp.loc['accuracy'])),0)
    print(collect.to_markdown(())We can now contrast the behavior of a fair classifier that relies on access to the protected attribute at test time with one that infers it.# we first create a classifier using the protected attribute
predictor=TabularPredictor(label='two_year_recid').fit(train_data=train)

fpredictor = FairPredictor(predictor, val, 'race', )

evaluate(fpredictor, gm.clarify_metrics)This returns the following table, which shows little drop in accuracy compared to the original and in some cases, even an improvement. N.B. Class Imbalance is a property of the dataset and cannot be updated.Measure (original)Measure (updated)Accuracy (original)Accuracy (updated)Class Imbalance0.1322030.1322030.6661390.663762Demographic Parity0.2834660.03282740.6661390.659406Disparate Impact0.5144360.9510210.6661390.677228Maximal Group Difference in Accuracy0.04699190.05325310.6661390.663762Maximal Group Difference in Recall0.2363780.005330190.6661390.67604Maximal Group Difference in Conditional Acceptance Rate0.3801710.05551070.6661390.670099Maximal Group Difference in Acceptance Rate0.02025940.04388920.6661390.658614Maximal Group Difference in Specificity0.2517290.08317560.6661390.664158Maximal Group Difference in Conditional Rejectance Rate0.290540.01071420.6661390.670891Maximal Group Difference in Rejection Rate0.06204990.07433510.6661390.663762Treatment Equality0.9335660.1593980.6661390.66099Generalized Entropy0.166270.05083680.6661390.442376In contrast, even though the base classifiers have similar accuracy, when using inferred attributes (N.B. the base classifier is not directly trained to maximize accuracy, which is why it can have higher accuracy when it doesn't use race), we see a much greater drop in accuracy as fairness is enforced which is consistent withLipton et al.# Now using the inferred attributes

fpredictor2 = FairPredictor(predictor2, val, 'race', inferred_groups=protected)

evaluate(fpredictor2,gm.clarify_metrics)Measure (original)Measure (updated)Accuracy (original)Accuracy (updated)Class Imbalance0.1322030.1322030.6728710.666535Demographic Parity0.217920.03445650.6728710.584158Disparate Impact0.5129050.8630170.6728710.563564Maximal Group Difference in Accuracy0.01472680.009767260.6728710.666535Maximal Group Difference in Recall0.2315390.1213190.6728710.583762Maximal Group Difference in Conditional Acceptance Rate0.5009410.002828870.6728710.601188Maximal Group Difference in Acceptance Rate0.07232720.1451990.6728710.585347Maximal Group Difference in Specificity0.1393060.03973640.6728710.593663Maximal Group Difference in Conditional Rejectance Rate0.0805290.008273870.6728710.662574Maximal Group Difference in Rejection Rate0.05485520.05569170.6728710.666535Treatment Equality0.321950.02771230.6728710.590099Generalized Entropy0.1964360.05083680.6728710.442376Similar results can be obtained using the metrics of Verma and Rubin, by runningevaluate(fpredictor, gm.verma_metrics)Measure (original)Measure (updated)Accuracy (original)Accuracy (updated)Statistical Parity0.2834660.03282740.6661390.659406Predictive Parity0.02025940.04388920.6661390.658614Maximal Group Difference in False Positive Rate0.2517290.07759690.6661390.667723Maximal Group Difference in False Negative Rate0.2363780.04210430.6661390.674455Equalized Odds0.2440530.01065390.6661390.673663Conditional Use Accuracy0.04115460.04686820.6661390.668119Predictive Equality0.2363780.04210430.6661390.674455Maximal Group Difference in Accuracy0.04699190.05325310.6661390.663762Treatment Equality0.9335660.1593980.6661390.66099andevaluate(fpredictor2, gm.verma_metrics)Measure (original)Measure (updated)Accuracy (original)Accuracy (updated)Statistical Parity0.217920.03445650.6728710.584158Predictive Parity0.07232720.1451990.6728710.585347Maximal Group Difference in False Positive Rate0.1393060.03973640.6728710.593663Maximal Group Difference in False Negative Rate0.2315390.1080810.6728710.582574Equalized Odds0.1854220.03096480.6728710.586535Conditional Use Accuracy0.06359120.06323380.6728710.627723Predictive Equality0.2315390.1080810.6728710.582574Maximal Group Difference in Accuracy0.01472680.009767260.6728710.666535Treatment Equality0.321950.02771230.6728710.590099Best PracticesIt is common for machine learning algorithms to overfit training data. Therefore, if you want your fairness constraints to carry over to unseen data we recommend that they are enforced on a large validation set, rather than the training set. For low-dimensional datasets, Autogluon predictors are robust to overfitting and fairness constraints enforced on training data carry over to unseen test data. In fact, given the choice between enforcing fairness constraints on a large training set, vs. using a significantly smaller validation set, reusing the training set will often result in better generalization of the desired behavior to unseen data. However, this behavior is not guaranteed, and should always be empirically validated.Challenges with unbalanced data.Many datasets are unbalanced both in the size of protected groups and in the prevalence of positive or negatively labeled data. When a rare group rarely receives positives outcomes, large datasets are needed to correctly estimate the rate of failure per group on positive data. This can make it very hard to reliably enforce or evaluate measures such as equal opportunity or minimum recall on unbalanced datasets, particularly where the baseline classifier has relatively high accuracy. The size and nature of the dataset needs to be carefully considered when choosing a fairness metric.For example, on the historic dataset 'adult'; African Americans, despite being the second largest ethnicity after Caucasian, only make up around 10% of the dataset, with only 10% of them earning over 50k (N.B. adult is based on census data from 1994, in the same dataset, around 20% of white people earned over 50k). If an algorithm had a 10% error rate on this subset of the data, we are concerned with the behavior of around 10%^3 i.e., 0.1% of the data. This problem becomes even greater when looking at less prevalent groups.For this reason, reliably guaranteeing high-accuracy across all groups, or that fairness measures are satisfied, requires access to rebalanced datasets, or much larger datasets than are needed for guaranteeing accuracy at the population level.The file../autogluon/examples/fair/sample_use.ipynbhas an example on the adult dataset where demographic parity is only weakly enforced on test data for the smaller groupsAmerican-Indian-Eskimo, andAsian-Pacific-Islanderdue to limited sample size.List of MeasuresThe remainder of the document lists the standard measures provided by the group_metrics library, which is imported as:from autogluon.fair.utils import group_metrics as gmBasic StructureThe majority of measures are defined as GroupMetrics or sub-objects of GroupMetrics.A group measure is specified by a function that takes the number of True Positives, False Positives, False Negatives, and True Negatives and returns a score; A string specifying the name of the of the measure; and optionally a bool indicating if greater values are better than smaller ones. For example, accuracy is defined as:accuracy = gm.GroupMetric(lambda TP, FP, FN, TN: (TP + TN) / (TP + FP + FN + TN), 'Accuracy')For efficiency, our approach relies on broadcast semantics and all operations in the function must be applicable to numpy arrays.Having defined a GroupMetric it can be called in two ways. Either:accuracy(target_labels, predictions, groups)Here target_labels and predictions are binary vectors corresponding to either the target ground-truth values, or the predictions made by a classifier, with 1 representing the positive label and 0 otherwise. Groups is simply a vector of values where each unique value is assumed to correspond to a distinct group.The other way it can be called is by passing it a single 3D array of dimension 4 by number of groups by k, where k is the number of candidate classifiers that the measure should be computed over.As a convenience, GroupMetrics automatically implements a range of functionality as sub-objects.Having defined a metric as above, we have a range of different objects:metric.av_diffreports the average absolute difference of the method between groups.metric.averagereports the average of the method taken over all groups.metric.diffreports the maximum difference of the method between any pair of groups.metric.maxreports the maximum value for any group.metric.minreports the minimum value for any group.metric.overallreports the overall value for all groups combined, and is the same as callingmetricdirectlymetric.ratioreports the smallest values for any group divided by the largestmetric.per_groupreports the value for every group.All of these can be passed directly to fit, or to the evaluation functions we provide.The vast majority of fairness metrics are implemented as a.diffof a standard performance measure, and by placing a.minafter any measure such asrecallorprecisionit is possible to add constraints that enforce that the precision or recall is above a particular value for every group.
gm.Dataset MeasuresNameDefinitiongm.countTotal number of points in a dataset or groupgm.pos_data_countTotal number of positively labeled points in a dataset or groupgm.neg_data_countTotal number of negatively labeled points in a dataset or groupgm.pos_data_rateRatio of positively labeled points to size of the groupgm.neg_data_rateRatio of negatively labeled points to size of the groupStandard Prediction MeasuresNameDefinitiongm.pos_pred_ratePositive Prediction Rate: Ratio of the number of positively predicted points to the size of the groupgm.neg_pred_rateNegative Prediction Rate: Ratio of the number of negatively predicted points to the size of the groupgm.true_pos_rateTrue Positive Rate: Ratio of true positives divided by total positive predictionsgm.true_neg_rateTrue Negative Rate: Ratio of true negatives divided by total negative predictionsgm.false_pos_rateFalse Positive Rate: Ratio of False Positives divided by total negative predictiongm.false_neg_rateFalse Negative Rate: Ratio of False Negatives divided by total positive predictionsgm.pos_pred_valPositive Predicted Value': Ratio of True Positives divided by the total number of points with positive labelgm.neg_pred_valNegative Predicted Value': Ratio of True Negatives divided by the total number of points with a negative labelCore Performance MeasuresNameDefinitiongm.accuracyProportion of points correctly identifiedgm.balanced_accuracyThe average of the proportion of points with a positive label correctly identified and the proportion of points with a negative label correctly identifiedgm.min_accuracyThe minimum of the proportion of points with a positive label correctly identified and the proportion of points with a negative label correctly identified (common in min-max fairness)gm.f1F1 Score. Defined as:  (2 * TP) / (2 * TP + FP + FN)gm.precisionAKA Positive Prediction Rategm.recallAKA True Positive Prediction Rategm.mccMatthews Correlation Coefficient. Seehttps://en.wikipedia.org/wiki/Phi_coefficientAdditional Performance MeasuresNameDefinitiongm.acceptance_rateAKA precision AKA Positive Prediction Rategm.cond_acceptConditional Acceptance Rate. The ratio of positive predictions to positive labelsgm.cond_rejectConditional Rejectance Rate. The ratio of negative predictions to negative labelsgm.specificityAKA True Negative Rategm.rejection_rateAKA Negative Predicted Valuegm.error_ratioThe ratio of False Positives to False NegativesFairness Measures SupportedSagemaker ClarifyMeasuresNameDefinitiongm.class_imbalanceMaximum difference between groups in Positive Data Rategm.demographic_parityAKA Statistical Parity.  Maximum difference between groups in Positive Prediction Rategm.disparate_impactThe smallest Positive Prediction Rate of any group divided by the largestgm.accuracy.diffMaximum difference between groups in Accuracygm.recall.diffAKA Equal Opportunity. Maximum difference between groups in Recallgm.cond_accept.diffMaximum difference between groups in Conditional Acceptance Rategm.acceptance_rate.diffMaximum difference between groups in Acceptance Rategm.specificity.diffMaximum difference between groups in Specificity  (or True Negative Rate)gm.cond_reject.diffMaximum difference between groups in Conditonal Rejectance Rategm.rejection_rate.diffMaximum difference between groups in Rejection Rate (or Negative Predicted Value)gm.treatment_equalityMaximum difference between groups in Error Ratiogm.gen_entropyThis is the expected square of a particular utility function divided by its expected value, minus 1 and then divided by 2. The function takes the form:TP*1+FP*2+FN*1, where TP, FP, NP, and TN are the true positives, false positives, false negatives and true negatives respectively.Measures fromVerma and Rubin.All the measures in Verma and Rubin are defined as strict equalities for two groups. We relax them into a continuous measure that reports the maximum difference over any pair of groups between the left and right sides of the equality.
These relaxations take value 0 only if the equalities are satisfied for all pairs of groups.NameDefinitiongm.statistical_parityAKA Demographic Parity. Maximum difference between groups in Positive Prediction Rategm.predictive_parityAKA Rejection Rate Difference. Maximum difference between groups in Precisiongm.false_pos_rate.diffAKA  Specificity Difference. Maximum difference between groups in False Positive rate.gm.false_neg_rate.diffAKA Equal Opportunity and Recall difference. Maximum difference between groups in False Negative Rategm.equalized_oddsThe average oftrue_pos_rate.diffandfalse_neg_rate.diffgm.cond_use_accuracyThe average ofpos_pred_val.diffandneg_pred_val.diffgm.predictive_equalityMaximum difference in False Negative Rategm.accuracy._parityMaximum difference in Accuracygm.treatment_equalityMaximum difference between groups in Error Ratio