Skip to main content

TensorFlow Model Remediation

Project description

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

Tutorial

Overview

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)[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.

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

# 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tensorflow_model_remediation-0.1.7.tar.gz (89.9 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file tensorflow_model_remediation-0.1.7.tar.gz.

File metadata

File hashes

Hashes for tensorflow_model_remediation-0.1.7.tar.gz
Algorithm Hash digest
SHA256 0331b4649cc3ce6741736df6b81c8de0ec6a9d3283d175be61453dc0fcb35962
MD5 f28905722a9870b048bfb7158e0ce965
BLAKE2b-256 8efda06543d5ee1e6cd9ca2af6f56d0e23e66a048f9e7f85a99ef03fc28ad107

See more details on using hashes here.

File details

Details for the file tensorflow_model_remediation-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for tensorflow_model_remediation-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ce2d255bcb2a23bfc10ff617753203ee7ca0f3e3f1b4b808550ed1fa03c7b94f
MD5 51f95913b2ff88c1a0e823b54cb90af3
BLAKE2b-256 07049f3ad03638e874990ef5367bda9c30895b3e1f1b32ebeb40b14501dd840f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page