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
Counterfactual tutorial notebook.
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.
tensorflow/model_remediation is Apache 2.0 licensed. See the
LICENSE file.
Metadata
Release files for tensorflow-model-remediation 0.1.7.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| tensorflow_model_remediation-0.1.7.1.tar.gz | 90.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tensorflow_model_remediation-0.1.7.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 232.0 kB
Release files / tensorflow_model_remediation-0.1.7.1.tar.gz
| Download URL | tensorflow_model_remediation-0.1.7.1.tar.gz |
|---|---|
| Size | 90.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2a6de477e6f9307f79d8930a2fff33a1c6e22397e15ccbb058c58bc0f2e4d1db
|
|
BLAKE2b-256 checksum How to use checksums |
6f3e06da67629dc3938426acdfd0b6d85819a53e38362e5fde66017ba91e3374
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.10
|
Release files / tensorflow_model_remediation-0.1.7.1-py3-none-any.whl
| Download URL | tensorflow_model_remediation-0.1.7.1-py3-none-any.whl |
|---|---|
| Size | 142.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0d90dcb8e27ab245ac61582d63f7422b30b344686cda698ffdd0a975daf631da
|
|
BLAKE2b-256 checksum How to use checksums |
f692f486877c646b2e393bd9e939e5cc074c9b6855cc936646c3aaf6f846f2f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.10
|
Security for tensorflow-model-remediation 0.1.7.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.