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.
Installation
You can install the package from pip
:
$ 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.
-
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.
We recommend starting with the
overview guide to
get an idea of TensorFlow Model Remediation. Next try one of our interactive
guides like the
MinDiff tutorial notebook.
Counterfactual tutorial notebook.
import tensorflow_model_remediation as tfmr
import tensorflow as tf
original_model = ...
min_diff_loss = tfmr.min_diff.losses.MMDLoss()
min_diff_weight = 1.0
min_diff_model = tfmr.min_diff.keras.MinDiffModel(
original_model, min_diff_loss, min_diff_weight)
min_diff_model.compile(...)
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.
tensorflow/model_remediation
is Apache 2.0 licensed. See the
LICENSE
file.