Overview
Stay organized with collections
Save and categorize content based on your preferences.
MinDiff is a model remediation technique that seeks to equalize two distributions.
In practice, it can be used to balance error rates across different slices of
your data by penalizing distributional differences.
Typically, you apply MinDiff when trying to ensure group fairness, such as
minimizing the difference in either
false positive rate (FPR) or false negative rate (FNR) between a slice of data
belonging to a sensitive class and a better-performing slice. For in-depth
discussion of fairness metrics, review the literature on this subject.123
How does MinDiff work?
Given two sets of examples from our dataset, MinDiff penalizes the model during
training for differences in the distribution of scores between the two sets.
The less distinguishable the two sets are based on prediction scores, the
smaller the penalty that will be applied.
The penalty is applied by adding a component to the loss that the model is using
for training. It can be thought of as a measurement of the difference in
distribution of model predictions. As the model trains, it tries to minimize
the penalty by bringing the distributions closer together, as shown in the
graphs below.

Applying MinDiff may come with tradeoffs with respect to performance on the original
task. MinDiff can be effective while not deteriorating
performance beyond product needs, but the decision to balance between performance
and effectiveness of MinDiff
should be made deliberately by the product owner. For examples showing how to implement
MinDiff, see the model remediation case study notebook.
Resources
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2022-05-11 UTC.
[null,null,["Last updated 2022-05-11 UTC."],[],[],null,["# Overview\n\n\u003cbr /\u003e\n\nMinDiff is a model remediation technique that seeks to equalize two distributions.\nIn practice, it can be used to balance error rates across different slices of\nyour data by penalizing distributional differences.\n\nTypically, you apply MinDiff when trying to ensure group fairness, such as\nminimizing the difference in either\nfalse positive rate (FPR) or false negative rate (FNR) between a slice of data\nbelonging to a sensitive class and a better-performing slice. For in-depth\ndiscussion of fairness metrics, review the literature on this subject.^[1](#fn1)^^[2](#fn2)^^[3](#fn3)^\n\nHow does MinDiff work?\n----------------------\n\nGiven two sets of examples from our dataset, MinDiff penalizes the model during\ntraining for differences in the distribution of scores between the two sets.\nThe less distinguishable the two sets are based on prediction scores, the\nsmaller the penalty that will be applied.\n\nThe penalty is applied by adding a component to the loss that the model is using\nfor training. It can be thought of as a measurement of the difference in\ndistribution of model predictions. As the model trains, it tries to minimize\nthe penalty by bringing the distributions closer together, as shown in the\ngraphs below.\n\nApplying MinDiff may come with tradeoffs with respect to performance on the original\ntask. MinDiff can be effective while not deteriorating\nperformance beyond product needs, but the decision to balance between performance\nand effectiveness of MinDiff\nshould be made deliberately by the product owner. For examples showing how to implement\nMinDiff, see [the model remediation case study notebook](/responsible_ai/model_remediation/min_diff/tutorials/min_diff_keras).\n\nResources\n---------\n\n- For a tutorial on applying MinDiff on a text classification model, see\n [MinDiff Keras notebook](/responsible_ai/model_remediation/min_diff/tutorials/min_diff_keras).\n\n- For a blog post on MinDiff on the TensorFlow blog, see\n [Applying MinDiff to improve model blog post](https://blog.tensorflow.org/2020/11/applying-mindiff-to-improve-model.html).\n\n- For the full Model Remediation library, see the\n [model-remediation Github repo](https://github.com/tensorflow/model-remediation).\n\n*** ** * ** ***\n\n1. Dwork, C., Hardt, M., Pitassi, T., Reingold, O., Zemel, R. (2011).\n [Fairness Through Awareness.](https://arxiv.org/abs/1104.3913) [↩](#fnref1)\n\n2. Hardt, M., Price, E., Srebro, N. (2016). [Equality of Opportunity in Supervised Learning.](https://arxiv.org/abs/1610.02413) [↩](#fnref2)\n\n3. Chouldechova, A. (2016). [Fair prediction with disparate impact: A study of bias in recidivism prediction instruments.](https://arxiv.org/abs/1610.07524) [↩](#fnref3)"]]