Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tensorflow/model-remediation
Model Remediation is a library that provides solutions for machine learning practitioners working to create and train models in a way that reduces or eliminates user harm resulting from underlying performance biases.
https://github.com/tensorflow/model-remediation
machine-learning tensorflow
Last synced: 10 days ago
JSON representation
Model Remediation is a library that provides solutions for machine learning practitioners working to create and train models in a way that reduces or eliminates user harm resulting from underlying performance biases.
- Host: GitHub
- URL: https://github.com/tensorflow/model-remediation
- Owner: tensorflow
- License: apache-2.0
- Archived: true
- Created: 2020-10-23T17:56:58.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-06T20:09:48.000Z (almost 2 years ago)
- Last Synced: 2025-01-16T14:26:15.838Z (14 days ago)
- Topics: machine-learning, tensorflow
- Language: Python
- Homepage: https://www.tensorflow.org/responsible_ai/model_remediation?hl=en
- Size: 1.44 MB
- Stars: 43
- Watchers: 15
- Forks: 20
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Authors: AUTHORS
Awesome Lists containing this project
README
# TensorFlow Model Remediation
TensorFlow Model Remediation is a library that provides solutions for machine
learning practitioners working to create and train models in a way that reduces
or eliminates user harm resulting from underlying performance biases.[![PyPI version](https://badge.fury.io/py/tensorflow-model-remediation.svg)](https://badge.fury.io/py/tensorflow-model-remediation)
[![Tutorial](https://img.shields.io/badge/doc-tutorial-blue.svg)](https://www.tensorflow.org/responsible_ai/model_remediation/min_diff/tutorials/min_diff_keras)
[![Overview](https://img.shields.io/badge/doc-overview-blue.svg)](https://www.tensorflow.org/responsible_ai/model_remediation)
## Installation
You can install the package from `pip`:
```shell
$ pip install tensorflow-model-remediation
```Note: Make sure you are using TensorFlow 2.x.
## Documentation
This library contains a collection of machine learning remediation techniques
for addressing potential bias in a model.Currently TensorFlow Model Remediation contains the below techniques:
* MinDiff technique: Typically used to ensure that a model predicts the
preferred label equally well for all values of a sensitive attribute.
Helpful when trying to achieve [equality of
opportunity](https://developers.google.com/machine-learning/glossary/fairness#equality-of-opportunity).* Counterfactual Logit Pairing technique: Typically used to ensure that a
model’s prediction does not change between “counterfactual pairs”, where the
sensitive attribute referenced in a feature is different. Helpful when
trying to achieve
[counterfactual fairness](https://developers.google.com/machine-learning/glossary/fairness#counterfactual-fairness).We recommend starting with the
[overview guide](https://www.tensorflow.org/responsible_ai/model_remediation) to
get an idea of TensorFlow Model Remediation. Next try one of our interactive
guides like the[MinDiff tutorial notebook](https://www.tensorflow.org/responsible_ai/model_remediation/min_diff/tutorials/min_diff_keras).
[Counterfactual tutorial notebook](https://www.tensorflow.org/responsible_ai/model_remediation/counterfactual/guide/counterfactual_keras).
```python
import tensorflow_model_remediation as tfmr
import tensorflow as tf
# Start by defining a Keras model.
original_model = ...
# Next pick the remediation technique you'd like to use. For example, a
# MinDiff implementation might look like the below:
# Set the MinDiff weight and choose a loss.min_diff_loss = tfmr.min_diff.losses.MMDLoss()
min_diff_weight = 1.0 # Hyperparamater to be tuned.
# Create a MinDiff model.
min_diff_model = tfmr.min_diff.keras.MinDiffModel(
original_model, min_diff_loss, min_diff_weight)
# Compile the MinDiff model as you normally would do with the original model.
min_diff_model.compile(...)
# Create a MinDiff Dataset and train the min_diff_model on it.
min_diff_model.fit(min_diff_dataset, ...)
```
#### *Disclaimers*
*If you're interested in learning more about responsible AI practices, including*
*fairness, please see Google AI's [Responsible AI Practices](https://ai.google/education/responsible-ai-practices).*
*`tensorflow/model_remediation` is Apache 2.0 licensed. See the
[`LICENSE`](LICENSE) file.*