Introduction to Fairness Indicators

View on TensorFlow.org Run in Google Colab View on GitHub Download notebook See TF Hub model

Overview

Fairness Indicators is a suite of tools built on top of TensorFlow Model Analysis (TFMA) that enable regular evaluation of fairness metrics in product pipelines. TFMA is a library for evaluating both TensorFlow and non-TensorFlow machine learning models. It allows you to evaluate your models on large amounts of data in a distributed manner, compute in-graph and other metrics over different slices of data, and visualize them in notebooks.

Fairness Indicators is packaged with TensorFlow Data Validation (TFDV) and the What-If Tool. Using Fairness Indicators allows you to:

  • Evaluate model performance, sliced across defined groups of users
  • Gain confidence about results with confidence intervals and evaluations at multiple thresholds
  • Evaluate the distribution of datasets
  • Dive deep into individual slices to explore root causes and opportunities for improvement

In this notebook, you will use Fairness Indicators to fix fairness issues in a model you train using the Civil Comments dataset. Watch this video for more details and context on the real-world scenario this is based on which is also one of primary motivations for creating Fairness Indicators.

Dataset

In this notebook, you will work with the Civil Comments dataset, approximately 2 million public comments made public by the Civil Comments platform in 2017 for ongoing research. This effort was sponsored by Jigsaw, who have hosted competitions on Kaggle to help classify toxic comments as well as minimize unintended model bias.

Each individual text comment in the dataset has a toxicity label, with the label being 1 if the comment is toxic and 0 if the comment is non-toxic. Within the data, a subset of comments are labeled with a variety of identity attributes, including categories for gender, sexual orientation, religion, and race or ethnicity.

Setup

Install fairness-indicators and witwidget.

pip install -q -U pip==20.2

pip install -q fairness-indicators
pip install -q witwidget

You must restart the Colab runtime after installing. Select Runtime > Restart runtime from the Colab menu.

Do not proceed with the rest of this tutorial without first restarting the runtime.

Import all other required libraries.

import os
import tempfile
import apache_beam as beam
import numpy as np
import pandas as pd
from datetime import datetime
import pprint

from google.protobuf import text_format

import tensorflow_hub as hub
import tensorflow as tf
import tensorflow_model_analysis as tfma
import tensorflow_data_validation as tfdv

from tfx_bsl.tfxio import tensor_adapter
from tfx_bsl.tfxio import tf_example_record

from tensorflow_model_analysis.addons.fairness.post_export_metrics import fairness_indicators
from tensorflow_model_analysis.addons.fairness.view import widget_view

from fairness_indicators.tutorial_utils import util

from witwidget.notebook.visualization import WitConfigBuilder
from witwidget.notebook.visualization import WitWidget

from tensorflow_metadata.proto.v0 import schema_pb2

Download and analyze the data

By default, this notebook downloads a preprocessed version of this dataset, but you may use the original dataset and re-run the processing steps if desired. In the original dataset, each comment is labeled with the percentage of raters who believed that a comment corresponds to a particular identity. For example, a comment might be labeled with the following: { male: 0.3, female: 1.0, transgender: 0.0, heterosexual: 0.8, homosexual_gay_or_lesbian: 1.0 } The processing step groups identity by category (gender, sexual_orientation, etc.) and removes identities with a score less than 0.5. So the example above would be converted to the following: of raters who believed that a comment corresponds to a particular identity. For example, the comment would be labeled with the following: { gender: [female], sexual_orientation: [heterosexual, homosexual_gay_or_lesbian] }

download_original_data = False

if download_original_data:
  train_tf_file = tf.keras.utils.get_file('train_tf.tfrecord',
                                          'https://storage.googleapis.com/civil_comments_dataset/train_tf.tfrecord')
  validate_tf_file = tf.keras.utils.get_file('validate_tf.tfrecord',
                                             'https://storage.googleapis.com/civil_comments_dataset/validate_tf.tfrecord')

  # The identity terms list will be grouped together by their categories
  # (see 'IDENTITY_COLUMNS') on threshould 0.5. Only the identity term column,
  # text column and label column will be kept after processing.
  train_tf_file = util.convert_comments_data(train_tf_file)
  validate_tf_file = util.convert_comments_data(validate_tf_file)

else:
  train_tf_file = tf.keras.utils.get_file('train_tf_processed.tfrecord',
                                          'https://storage.googleapis.com/civil_comments_dataset/train_tf_processed.tfrecord')
  validate_tf_file = tf.keras.utils.get_file('validate_tf_processed.tfrecord',
                                             'https://storage.googleapis.com/civil_comments_dataset/validate_tf_processed.tfrecord')

Use TFDV to analyze the data and find potential problems in it, such as missing values and data imbalances, that can lead to fairness disparities.

stats = tfdv.generate_statistics_from_tfrecord(data_location=train_tf_file)
tfdv.visualize_statistics(stats)
WARNING:apache_beam.runners.interactive.interactive_environment:Dependencies required for Interactive Beam PCollection visualization are not available, please use: `pip install apache-beam[interactive]` to install necessary dependencies to enable all data visualization features.
WARNING:apache_beam.io.tfrecordio:Couldn't find python-snappy so the implementation of _TFRecordUtil._masked_crc32c is not as fast as it could be.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_data_validation/utils/artifacts_io_impl.py:93: tf_record_iterator (from tensorflow.python.lib.io.tf_record) is deprecated and will be removed in a future version.
Instructions for updating:
Use eager execution and: 
`tf.data.TFRecordDataset(path)`
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_data_validation/utils/artifacts_io_impl.py:93: tf_record_iterator (from tensorflow.python.lib.io.tf_record) is deprecated and will be removed in a future version.
Instructions for updating:
Use eager execution and: 
`tf.data.TFRecordDataset(path)`

TFDV shows that there are some significant imbalances in the data which could lead to biased model outcomes.

  • The toxicity label (the value predicted by the model) is unbalanced. Only 8% of the examples in the training set are toxic, which means that a classifier could get 92% accuracy by predicting that all comments are non-toxic.

  • In the fields relating to identity terms, only 6.6k out of the 1.08 million (0.61%) training examples deal with homosexuality, and those related to bisexuality are even more rare. This indicates that performance on these slices may suffer due to lack of training data.

Prepare the data

Define a feature map to parse the data. Each example will have a label, comment text, and identity features sexual orientation, gender, religion, race, and disability that are associated with the text.

BASE_DIR = tempfile.gettempdir()

TEXT_FEATURE = 'comment_text'
LABEL = 'toxicity'
FEATURE_MAP = {
    # Label:
    LABEL: tf.io.FixedLenFeature([], tf.float32),
    # Text:
    TEXT_FEATURE:  tf.io.FixedLenFeature([], tf.string),

    # Identities:
    'sexual_orientation':tf.io.VarLenFeature(tf.string),
    'gender':tf.io.VarLenFeature(tf.string),
    'religion':tf.io.VarLenFeature(tf.string),
    'race':tf.io.VarLenFeature(tf.string),
    'disability':tf.io.VarLenFeature(tf.string),
}

Next, set up an input function to feed data into the model. Add a weight column to each example and upweight the toxic examples to account for the class imbalance identified by the TFDV. Use only identity features during the evaluation phase, as only the comments are fed into the model during training.

def train_input_fn():
  def parse_function(serialized):
    parsed_example = tf.io.parse_single_example(
        serialized=serialized, features=FEATURE_MAP)
    # Adds a weight column to deal with unbalanced classes.
    parsed_example['weight'] = tf.add(parsed_example[LABEL], 0.1)
    return (parsed_example,
            parsed_example[LABEL])
  train_dataset = tf.data.TFRecordDataset(
      filenames=[train_tf_file]).map(parse_function).batch(512)
  return train_dataset

Train the model

Create and train a deep learning model on the data.

model_dir = os.path.join(BASE_DIR, 'train', datetime.now().strftime(
    "%Y%m%d-%H%M%S"))

embedded_text_feature_column = hub.text_embedding_column(
    key=TEXT_FEATURE,
    module_spec='https://tfhub.dev/google/nnlm-en-dim128/1')

classifier = tf.estimator.DNNClassifier(
    hidden_units=[500, 100],
    weight_column='weight',
    feature_columns=[embedded_text_feature_column],
    optimizer=tf.keras.optimizers.legacy.Adagrad(learning_rate=0.003),
    loss_reduction=tf.losses.Reduction.SUM,
    n_classes=2,
    model_dir=model_dir)

classifier.train(input_fn=train_input_fn, steps=1000)
WARNING:tensorflow:From /tmpfs/tmp/ipykernel_26472/1522786676.py:8: DNNClassifierV2.__init__ (from tensorflow_estimator.python.estimator.canned.dnn) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/tmp/ipykernel_26472/1522786676.py:8: DNNClassifierV2.__init__ (from tensorflow_estimator.python.estimator.canned.dnn) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/head/head_utils.py:54: BinaryClassHead.__init__ (from tensorflow_estimator.python.estimator.head.binary_class_head) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/head/head_utils.py:54: BinaryClassHead.__init__ (from tensorflow_estimator.python.estimator.head.binary_class_head) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/canned/dnn.py:759: Estimator.__init__ (from tensorflow_estimator.python.estimator.estimator) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/canned/dnn.py:759: Estimator.__init__ (from tensorflow_estimator.python.estimator.estimator) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/estimator.py:1842: RunConfig.__init__ (from tensorflow_estimator.python.estimator.run_config) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/estimator.py:1842: RunConfig.__init__ (from tensorflow_estimator.python.estimator.run_config) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
INFO:tensorflow:Using default config.
INFO:tensorflow:Using default config.
INFO:tensorflow:Using config: {'_model_dir': '/tmpfs/tmp/train/20230810-093829', '_tf_random_seed': None, '_save_summary_steps': 100, '_save_checkpoints_steps': None, '_save_checkpoints_secs': 600, '_session_config': allow_soft_placement: true
graph_options {
  rewrite_options {
    meta_optimizer_iterations: ONE
  }
}
, '_keep_checkpoint_max': 5, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': 100, '_train_distribute': None, '_device_fn': None, '_protocol': None, '_eval_distribute': None, '_experimental_distribute': None, '_experimental_max_worker_delay_secs': None, '_session_creation_timeout_secs': 7200, '_checkpoint_save_graph_def': True, '_service': None, '_cluster_spec': ClusterSpec({}), '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1}
INFO:tensorflow:Using config: {'_model_dir': '/tmpfs/tmp/train/20230810-093829', '_tf_random_seed': None, '_save_summary_steps': 100, '_save_checkpoints_steps': None, '_save_checkpoints_secs': 600, '_session_config': allow_soft_placement: true
graph_options {
  rewrite_options {
    meta_optimizer_iterations: ONE
  }
}
, '_keep_checkpoint_max': 5, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': 100, '_train_distribute': None, '_device_fn': None, '_protocol': None, '_eval_distribute': None, '_experimental_distribute': None, '_experimental_max_worker_delay_secs': None, '_session_creation_timeout_secs': 7200, '_checkpoint_save_graph_def': True, '_service': None, '_cluster_spec': ClusterSpec({}), '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1}
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/estimator.py:385: StopAtStepHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/estimator.py:385: StopAtStepHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow/python/training/training_util.py:396: Variable.initialized_value (from tensorflow.python.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Use Variable.read_value. Variables in 2.X are initialized automatically both in eager and graph (inside tf.defun) contexts.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow/python/training/training_util.py:396: Variable.initialized_value (from tensorflow.python.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Use Variable.read_value. Variables in 2.X are initialized automatically both in eager and graph (inside tf.defun) contexts.
INFO:tensorflow:Calling model_fn.
INFO:tensorflow:Calling model_fn.
2023-08-10 09:38:30.585306: W tensorflow/core/common_runtime/graph_constructor.cc:1533] Importing a graph with a lower producer version 26 into an existing graph with producer version 1395. Shape inference will have run different parts of the graph with different producer versions.
INFO:tensorflow:Saver not created because there are no variables in the graph to restore
INFO:tensorflow:Saver not created because there are no variables in the graph to restore
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/head/base_head.py:505: numeric_column (from tensorflow.python.feature_column.feature_column_v2) is deprecated and will be removed in a future version.
Instructions for updating:
Use Keras preprocessing layers instead, either directly or via the `tf.keras.utils.FeatureSpace` utility. Each of `tf.feature_column.*` has a functional equivalent in `tf.keras.layers` for feature preprocessing when training a Keras model.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/head/base_head.py:505: numeric_column (from tensorflow.python.feature_column.feature_column_v2) is deprecated and will be removed in a future version.
Instructions for updating:
Use Keras preprocessing layers instead, either directly or via the `tf.keras.utils.FeatureSpace` utility. Each of `tf.feature_column.*` has a functional equivalent in `tf.keras.layers` for feature preprocessing when training a Keras model.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/head/base_head.py:511: NumericColumn._get_dense_tensor (from tensorflow.python.feature_column.feature_column_v2) is deprecated and will be removed in a future version.
Instructions for updating:
The old _FeatureColumn APIs are being deprecated. Please use the new FeatureColumn APIs instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/head/base_head.py:511: NumericColumn._get_dense_tensor (from tensorflow.python.feature_column.feature_column_v2) is deprecated and will be removed in a future version.
Instructions for updating:
The old _FeatureColumn APIs are being deprecated. Please use the new FeatureColumn APIs instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow/python/feature_column/feature_column.py:2206: NumericColumn._transform_feature (from tensorflow.python.feature_column.feature_column_v2) is deprecated and will be removed in a future version.
Instructions for updating:
The old _FeatureColumn APIs are being deprecated. Please use the new FeatureColumn APIs instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow/python/feature_column/feature_column.py:2206: NumericColumn._transform_feature (from tensorflow.python.feature_column.feature_column_v2) is deprecated and will be removed in a future version.
Instructions for updating:
The old _FeatureColumn APIs are being deprecated. Please use the new FeatureColumn APIs instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/keras/optimizers/legacy/adagrad.py:93: calling Constant.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.
Instructions for updating:
Call initializer instance with the dtype argument instead of passing it to the constructor
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/keras/optimizers/legacy/adagrad.py:93: calling Constant.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.
Instructions for updating:
Call initializer instance with the dtype argument instead of passing it to the constructor
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/model_fn.py:250: EstimatorSpec.__new__ (from tensorflow_estimator.python.estimator.model_fn) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/model_fn.py:250: EstimatorSpec.__new__ (from tensorflow_estimator.python.estimator.model_fn) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
INFO:tensorflow:Done calling model_fn.
INFO:tensorflow:Done calling model_fn.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/estimator.py:1414: NanTensorHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/estimator.py:1414: NanTensorHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/estimator.py:1417: LoggingTensorHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/estimator.py:1417: LoggingTensorHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow/python/training/basic_session_run_hooks.py:232: SecondOrStepTimer.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow/python/training/basic_session_run_hooks.py:232: SecondOrStepTimer.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/estimator.py:1454: CheckpointSaverHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/estimator.py:1454: CheckpointSaverHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
INFO:tensorflow:Create CheckpointSaverHook.
INFO:tensorflow:Create CheckpointSaverHook.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow/python/training/monitored_session.py:579: StepCounterHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow/python/training/monitored_session.py:579: StepCounterHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow/python/training/monitored_session.py:586: SummarySaverHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow/python/training/monitored_session.py:586: SummarySaverHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
INFO:tensorflow:Graph was finalized.
INFO:tensorflow:Graph was finalized.
2023-08-10 09:38:35.172095: W tensorflow/core/common_runtime/type_inference.cc:339] Type inference failed. This indicates an invalid graph that escaped type checking. Error message: INVALID_ARGUMENT: expected compatible input types, but input 1:
type_id: TFT_OPTIONAL
args {
  type_id: TFT_PRODUCT
  args {
    type_id: TFT_TENSOR
    args {
      type_id: TFT_INT64
    }
  }
}
 is neither a subtype nor a supertype of the combined inputs preceding it:
type_id: TFT_OPTIONAL
args {
  type_id: TFT_PRODUCT
  args {
    type_id: TFT_TENSOR
    args {
      type_id: TFT_INT32
    }
  }
}

    while inferring type of node 'dnn/zero_fraction/cond/output/_18'
INFO:tensorflow:Running local_init_op.
INFO:tensorflow:Running local_init_op.
INFO:tensorflow:Done running local_init_op.
INFO:tensorflow:Done running local_init_op.
INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 0...
INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 0...
INFO:tensorflow:Saving checkpoints for 0 into /tmpfs/tmp/train/20230810-093829/model.ckpt.
INFO:tensorflow:Saving checkpoints for 0 into /tmpfs/tmp/train/20230810-093829/model.ckpt.
INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 0...
INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 0...
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow/python/training/monitored_session.py:1455: SessionRunArgs.__new__ (from tensorflow.python.training.session_run_hook) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow/python/training/monitored_session.py:1455: SessionRunArgs.__new__ (from tensorflow.python.training.session_run_hook) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow/python/training/monitored_session.py:1454: SessionRunContext.__init__ (from tensorflow.python.training.session_run_hook) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow/python/training/monitored_session.py:1454: SessionRunContext.__init__ (from tensorflow.python.training.session_run_hook) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow/python/training/monitored_session.py:1474: SessionRunValues.__new__ (from tensorflow.python.training.session_run_hook) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow/python/training/monitored_session.py:1474: SessionRunValues.__new__ (from tensorflow.python.training.session_run_hook) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
INFO:tensorflow:loss = 59.03337, step = 0
INFO:tensorflow:loss = 59.03337, step = 0
INFO:tensorflow:global_step/sec: 108.922
INFO:tensorflow:global_step/sec: 108.922
INFO:tensorflow:loss = 56.35042, step = 100 (0.920 sec)
INFO:tensorflow:loss = 56.35042, step = 100 (0.920 sec)
INFO:tensorflow:global_step/sec: 121.077
INFO:tensorflow:global_step/sec: 121.077
INFO:tensorflow:loss = 47.494476, step = 200 (0.826 sec)
INFO:tensorflow:loss = 47.494476, step = 200 (0.826 sec)
INFO:tensorflow:global_step/sec: 124.138
INFO:tensorflow:global_step/sec: 124.138
INFO:tensorflow:loss = 55.630802, step = 300 (0.806 sec)
INFO:tensorflow:loss = 55.630802, step = 300 (0.806 sec)
INFO:tensorflow:global_step/sec: 121.691
INFO:tensorflow:global_step/sec: 121.691
INFO:tensorflow:loss = 56.19299, step = 400 (0.822 sec)
INFO:tensorflow:loss = 56.19299, step = 400 (0.822 sec)
INFO:tensorflow:global_step/sec: 123.696
INFO:tensorflow:global_step/sec: 123.696
INFO:tensorflow:loss = 41.49157, step = 500 (0.809 sec)
INFO:tensorflow:loss = 41.49157, step = 500 (0.809 sec)
INFO:tensorflow:global_step/sec: 125.493
INFO:tensorflow:global_step/sec: 125.493
INFO:tensorflow:loss = 45.425648, step = 600 (0.797 sec)
INFO:tensorflow:loss = 45.425648, step = 600 (0.797 sec)
INFO:tensorflow:global_step/sec: 121.932
INFO:tensorflow:global_step/sec: 121.932
INFO:tensorflow:loss = 51.707657, step = 700 (0.820 sec)
INFO:tensorflow:loss = 51.707657, step = 700 (0.820 sec)
INFO:tensorflow:global_step/sec: 122.042
INFO:tensorflow:global_step/sec: 122.042
INFO:tensorflow:loss = 47.744106, step = 800 (0.820 sec)
INFO:tensorflow:loss = 47.744106, step = 800 (0.820 sec)
INFO:tensorflow:global_step/sec: 123.501
INFO:tensorflow:global_step/sec: 123.501
INFO:tensorflow:loss = 48.116207, step = 900 (0.810 sec)
INFO:tensorflow:loss = 48.116207, step = 900 (0.810 sec)
INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 1000...
INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 1000...
INFO:tensorflow:Saving checkpoints for 1000 into /tmpfs/tmp/train/20230810-093829/model.ckpt.
INFO:tensorflow:Saving checkpoints for 1000 into /tmpfs/tmp/train/20230810-093829/model.ckpt.
INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 1000...
INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 1000...
INFO:tensorflow:Loss for final step: 50.987305.
INFO:tensorflow:Loss for final step: 50.987305.
<tensorflow_estimator.python.estimator.canned.dnn.DNNClassifierV2 at 0x7fb2af9743d0>

Analyze the model

After obtaining the trained model, analyze it to compute fairness metrics using TFMA and Fairness Indicators. Begin by exporting the model as a SavedModel.

Export SavedModel

def eval_input_receiver_fn():
  serialized_tf_example = tf.compat.v1.placeholder(
      dtype=tf.string, shape=[None], name='input_example_placeholder')

  # This *must* be a dictionary containing a single key 'examples', which
  # points to the input placeholder.
  receiver_tensors = {'examples': serialized_tf_example}

  features = tf.io.parse_example(serialized_tf_example, FEATURE_MAP)
  features['weight'] = tf.ones_like(features[LABEL])

  return tfma.export.EvalInputReceiver(
    features=features,
    receiver_tensors=receiver_tensors,
    labels=features[LABEL])

tfma_export_dir = tfma.export.export_eval_savedmodel(
  estimator=classifier,
  export_dir_base=os.path.join(BASE_DIR, 'tfma_eval_model'),
  eval_input_receiver_fn=eval_input_receiver_fn)
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_model_analysis/eval_saved_model/encoding.py:132: build_tensor_info (from tensorflow.python.saved_model.utils_impl) is deprecated and will be removed in a future version.
Instructions for updating:
This API was designed for TensorFlow v1. See https://www.tensorflow.org/guide/migrate for instructions on how to migrate your code to TensorFlow v2.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_model_analysis/eval_saved_model/encoding.py:132: build_tensor_info (from tensorflow.python.saved_model.utils_impl) is deprecated and will be removed in a future version.
Instructions for updating:
This API was designed for TensorFlow v1. See https://www.tensorflow.org/guide/migrate for instructions on how to migrate your code to TensorFlow v2.
INFO:tensorflow:Calling model_fn.
INFO:tensorflow:Calling model_fn.
INFO:tensorflow:Saver not created because there are no variables in the graph to restore
2023-08-10 09:38:47.576489: W tensorflow/core/common_runtime/graph_constructor.cc:1533] Importing a graph with a lower producer version 26 into an existing graph with producer version 1395. Shape inference will have run different parts of the graph with different producer versions.
INFO:tensorflow:Saver not created because there are no variables in the graph to restore
INFO:tensorflow:Done calling model_fn.
INFO:tensorflow:Done calling model_fn.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow/python/saved_model/model_utils/export_utils.py:346: _SupervisedOutput.__init__ (from tensorflow.python.saved_model.model_utils.export_output) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow/python/saved_model/model_utils/export_utils.py:346: _SupervisedOutput.__init__ (from tensorflow.python.saved_model.model_utils.export_output) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.keras instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow/python/saved_model/model_utils/export_utils.py:84: get_tensor_from_tensor_info (from tensorflow.python.saved_model.utils_impl) is deprecated and will be removed in a future version.
Instructions for updating:
This API was designed for TensorFlow v1. See https://www.tensorflow.org/guide/migrate for instructions on how to migrate your code to TensorFlow v2.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow/python/saved_model/model_utils/export_utils.py:84: get_tensor_from_tensor_info (from tensorflow.python.saved_model.utils_impl) is deprecated and will be removed in a future version.
Instructions for updating:
This API was designed for TensorFlow v1. See https://www.tensorflow.org/guide/migrate for instructions on how to migrate your code to TensorFlow v2.
INFO:tensorflow:Signatures INCLUDED in export for Classify: None
INFO:tensorflow:Signatures INCLUDED in export for Classify: None
INFO:tensorflow:Signatures INCLUDED in export for Regress: None
INFO:tensorflow:Signatures INCLUDED in export for Regress: None
INFO:tensorflow:Signatures INCLUDED in export for Predict: None
INFO:tensorflow:Signatures INCLUDED in export for Predict: None
INFO:tensorflow:Signatures INCLUDED in export for Train: None
INFO:tensorflow:Signatures INCLUDED in export for Train: None
INFO:tensorflow:Signatures INCLUDED in export for Eval: ['eval']
INFO:tensorflow:Signatures INCLUDED in export for Eval: ['eval']
WARNING:tensorflow:Export includes no default signature!
WARNING:tensorflow:Export includes no default signature!
INFO:tensorflow:Restoring parameters from /tmpfs/tmp/train/20230810-093829/model.ckpt-1000
INFO:tensorflow:Restoring parameters from /tmpfs/tmp/train/20230810-093829/model.ckpt-1000
INFO:tensorflow:Assets added to graph.
INFO:tensorflow:Assets added to graph.
INFO:tensorflow:Assets written to: /tmpfs/tmp/tfma_eval_model/temp-1691660327/assets
INFO:tensorflow:Assets written to: /tmpfs/tmp/tfma_eval_model/temp-1691660327/assets
INFO:tensorflow:SavedModel written to: /tmpfs/tmp/tfma_eval_model/temp-1691660327/saved_model.pb
INFO:tensorflow:SavedModel written to: /tmpfs/tmp/tfma_eval_model/temp-1691660327/saved_model.pb

Compute Fairness Metrics

Select the identity to compute metrics for and whether to run with confidence intervals using the dropdown in the panel on the right.

Fairness Indicators Computation Options

Slice selection: sexual_orientation
Compute confidence intervals: False
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_model_analysis/eval_saved_model/load.py:163: load (from tensorflow.python.saved_model.loader_impl) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.saved_model.load` instead.
WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.8/site-packages/tensorflow_model_analysis/eval_saved_model/load.py:163: load (from tensorflow.python.saved_model.loader_impl) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.saved_model.load` instead.
INFO:tensorflow:Restoring parameters from /tmpfs/tmp/tfma_eval_model/1691660327/variables/variables
INFO:tensorflow:Restoring parameters from /tmpfs/tmp/tfma_eval_model/1691660327/variables/variables
2023-08-10 09:38:52.989126: W tensorflow/c/c_api.cc:300] Operation '{name:'head/metrics/true_positives_1/Assign' id:498 op device:{requested: '', assigned: ''} def:{ { {node head/metrics/true_positives_1/Assign} } = AssignVariableOp[_has_manual_control_dependencies=true, dtype=DT_FLOAT, validate_shape=false](head/metrics/true_positives_1, head/metrics/true_positives_1/Initializer/zeros)} }' was changed by setting attribute after it was run by a session. This mutation will have no effect, and will trigger an error in the future. Either don't modify nodes after running them or create a new session.
2023-08-10 09:38:53.121385: W tensorflow/c/c_api.cc:300] Operation '{name:'head/metrics/true_positives_1/Assign' id:498 op device:{requested: '', assigned: ''} def:{ { {node head/metrics/true_positives_1/Assign} } = AssignVariableOp[_has_manual_control_dependencies=true, dtype=DT_FLOAT, validate_shape=false](head/metrics/true_positives_1, head/metrics/true_positives_1/Initializer/zeros)} }' was changed by setting attribute after it was run by a session. This mutation will have no effect, and will trigger an error in the future. Either don't modify nodes after running them or create a new session.

Visualize data using the What-if Tool

In this section, you'll use the What-If Tool's interactive visual interface to explore and manipulate data at a micro-level.

Each point on the scatter plot on the right-hand panel represents one of the examples in the subset loaded into the tool. Click on one of the points to see details about this particular example in the left-hand panel. The comment text, ground truth toxicity, and applicable identities are shown. At the bottom of this left-hand panel, you see the inference results from the model you just trained.

Modify the text of the example and then click the Run inference button to view how your changes caused the perceived toxicity prediction to change.

DEFAULT_MAX_EXAMPLES = 1000

# Load 100000 examples in memory. When first rendered, 
# What-If Tool should only display 1000 of these due to browser constraints.
def wit_dataset(file, num_examples=100000):
  dataset = tf.data.TFRecordDataset(
      filenames=[file]).take(num_examples)
  return [tf.train.Example.FromString(d.numpy()) for d in dataset]

wit_data = wit_dataset(train_tf_file)
config_builder = WitConfigBuilder(wit_data[:DEFAULT_MAX_EXAMPLES]).set_estimator_and_feature_spec(
    classifier, FEATURE_MAP).set_label_vocab(['non-toxicity', LABEL]).set_target_feature(LABEL)
wit = WitWidget(config_builder)

Render Fairness Indicators

Render the Fairness Indicators widget with the exported evaluation results.

Below you will see bar charts displaying performance of each slice of the data on selected metrics. You can adjust the baseline comparison slice as well as the displayed threshold(s) using the dropdown menus at the top of the visualization.

The Fairness Indicator widget is integrated with the What-If Tool rendered above. If you select one slice of the data in the bar chart, the What-If Tool will update to show you examples from the selected slice. When the data reloads in the What-If Tool above, try modifying Color By to toxicity. This can give you a visual understanding of the toxicity balance of examples by slice.

event_handlers={'slice-selected':
                wit.create_selection_callback(wit_data, DEFAULT_MAX_EXAMPLES)}
widget_view.render_fairness_indicator(eval_result=eval_result,
                                      slicing_column=slice_selection,
                                      event_handlers=event_handlers
                                      )
FairnessIndicatorViewer(slicingMetrics=[{'sliceValue': 'Overall', 'slice': 'Overall', 'metrics': {'auc': {'dou…

With this particular dataset and task, systematically higher false positive and false negative rates for certain identities can lead to negative consequences. For example, in a content moderation system, a higher-than-overall false positive rate for a certain group can lead to those voices being silenced. Thus, it is important to regularly evaluate these types of criteria as you develop and improve models, and utilize tools such as Fairness Indicators, TFDV, and WIT to help illuminate potential problems. Once you've identified fairness issues, you can experiment with new data sources, data balancing, or other techniques to improve performance on underperforming groups.

See here for more information and guidance on how to use Fairness Indicators.

Use fairness evaluation results

The eval_result object, rendered above in render_fairness_indicator(), has its own API that you can leverage to read TFMA results into your programs.

Get evaluated slices and metrics

Use get_slice_names() and get_metric_names() to get the evaluated slices and metrics, respectively.

pp = pprint.PrettyPrinter()

print("Slices:")
pp.pprint(eval_result.get_slice_names())
print("\nMetrics:")
pp.pprint(eval_result.get_metric_names())
Slices:
[(),
 (('sexual_orientation', 'homosexual_gay_or_lesbian'),),
 (('sexual_orientation', 'heterosexual'),),
 (('sexual_orientation', 'bisexual'),),
 (('sexual_orientation', 'other_sexual_orientation'),)]

Metrics:
['fairness_indicators_metrics/precision@0.7',
 'fairness_indicators_metrics/false_discovery_rate@0.9',
 'post_export_metrics/example_count',
 'fairness_indicators_metrics/false_positive_rate@0.1',
 'recall',
 'fairness_indicators_metrics/recall@0.7',
 'fairness_indicators_metrics/false_discovery_rate@0.1',
 'fairness_indicators_metrics/false_positive_rate@0.7',
 'fairness_indicators_metrics/recall@0.3',
 'accuracy',
 'fairness_indicators_metrics/false_negative_rate@0.7',
 'fairness_indicators_metrics/true_positive_rate@0.1',
 'fairness_indicators_metrics/true_positive_rate@0.3',
 'fairness_indicators_metrics/false_omission_rate@0.1',
 'fairness_indicators_metrics/true_positive_rate@0.5',
 'fairness_indicators_metrics/recall@0.9',
 'fairness_indicators_metrics/negative_rate@0.1',
 'fairness_indicators_metrics/precision@0.3',
 'fairness_indicators_metrics/false_positive_rate@0.5',
 'fairness_indicators_metrics/negative_rate@0.7',
 'fairness_indicators_metrics/precision@0.9',
 'fairness_indicators_metrics/positive_rate@0.9',
 'fairness_indicators_metrics/positive_rate@0.7',
 'fairness_indicators_metrics/positive_rate@0.1',
 'fairness_indicators_metrics/false_omission_rate@0.3',
 'average_loss',
 'fairness_indicators_metrics/precision@0.1',
 'fairness_indicators_metrics/true_negative_rate@0.5',
 'fairness_indicators_metrics/false_positive_rate@0.3',
 'fairness_indicators_metrics/true_negative_rate@0.3',
 'fairness_indicators_metrics/true_positive_rate@0.9',
 'fairness_indicators_metrics/recall@0.1',
 'fairness_indicators_metrics/true_negative_rate@0.1',
 'precision',
 'fairness_indicators_metrics/false_omission_rate@0.5',
 'fairness_indicators_metrics/negative_rate@0.5',
 'label/mean',
 'auc',
 'fairness_indicators_metrics/negative_rate@0.9',
 'fairness_indicators_metrics/positive_rate@0.3',
 'fairness_indicators_metrics/false_discovery_rate@0.5',
 'fairness_indicators_metrics/false_discovery_rate@0.7',
 'fairness_indicators_metrics/false_negative_rate@0.5',
 'auc_precision_recall',
 'fairness_indicators_metrics/false_negative_rate@0.1',
 'fairness_indicators_metrics/positive_rate@0.5',
 'fairness_indicators_metrics/true_negative_rate@0.9',
 'fairness_indicators_metrics/false_omission_rate@0.9',
 'fairness_indicators_metrics/false_discovery_rate@0.3',
 'fairness_indicators_metrics/false_omission_rate@0.7',
 'fairness_indicators_metrics/false_positive_rate@0.9',
 'fairness_indicators_metrics/true_negative_rate@0.7',
 'fairness_indicators_metrics/false_negative_rate@0.3',
 'accuracy_baseline',
 'fairness_indicators_metrics/negative_rate@0.3',
 'prediction/mean',
 'fairness_indicators_metrics/recall@0.5',
 'fairness_indicators_metrics/false_negative_rate@0.9',
 'fairness_indicators_metrics/precision@0.5',
 'fairness_indicators_metrics/true_positive_rate@0.7']

Use get_metrics_for_slice() to get the metrics for a particular slice as a dictionary mapping metric names to metric values.

baseline_slice = ()
heterosexual_slice = (('sexual_orientation', 'heterosexual'),)

print("Baseline metric values:")
pp.pprint(eval_result.get_metrics_for_slice(baseline_slice))
print("\nHeterosexual metric values:")
pp.pprint(eval_result.get_metrics_for_slice(heterosexual_slice))
Baseline metric values:
{'accuracy': {'doubleValue': 0.7173363566398621},
 'accuracy_baseline': {'doubleValue': 0.9198060631752014},
 'auc': {'doubleValue': 0.7970057725906372},
 'auc_precision_recall': {'doubleValue': 0.30066317319869995},
 'average_loss': {'doubleValue': 0.5619063377380371},
 'fairness_indicators_metrics/false_discovery_rate@0.1': {'doubleValue': 0.913892210371306},
 'fairness_indicators_metrics/false_discovery_rate@0.3': {'doubleValue': 0.87946203635518},
 'fairness_indicators_metrics/false_discovery_rate@0.5': {'doubleValue': 0.8166508528622985},
 'fairness_indicators_metrics/false_discovery_rate@0.7': {'doubleValue': 0.7093297111371578},
 'fairness_indicators_metrics/false_discovery_rate@0.9': {'doubleValue': 0.48458434221146085},
 'fairness_indicators_metrics/false_negative_rate@0.1': {'doubleValue': 0.006183501450877435},
 'fairness_indicators_metrics/false_negative_rate@0.3': {'doubleValue': 0.08681083321818434},
 'fairness_indicators_metrics/false_negative_rate@0.5': {'doubleValue': 0.2690514025148542},
 'fairness_indicators_metrics/false_negative_rate@0.7': {'doubleValue': 0.5416781815669476},
 'fairness_indicators_metrics/false_negative_rate@0.9': {'doubleValue': 0.88969877020865},
 'fairness_indicators_metrics/false_omission_rate@0.1': {'doubleValue': 0.006661580543718949},
 'fairness_indicators_metrics/false_omission_rate@0.3': {'doubleValue': 0.017738844398640468},
 'fairness_indicators_metrics/false_omission_rate@0.5': {'doubleValue': 0.03171607223209723},
 'fairness_indicators_metrics/false_omission_rate@0.7': {'doubleValue': 0.04972719099484509},
 'fairness_indicators_metrics/false_omission_rate@0.9': {'doubleValue': 0.07259428378149839},
 'fairness_indicators_metrics/false_positive_rate@0.1': {'doubleValue': 0.9196104533667443},
 'fairness_indicators_metrics/false_positive_rate@0.3': {'doubleValue': 0.5808970354820542},
 'fairness_indicators_metrics/false_positive_rate@0.5': {'doubleValue': 0.2838504097558331},
 'fairness_indicators_metrics/false_positive_rate@0.7': {'doubleValue': 0.09751315405072479},
 'fairness_indicators_metrics/false_positive_rate@0.9': {'doubleValue': 0.009041433377406054},
 'fairness_indicators_metrics/negative_rate@0.1': {'doubleValue': 0.07443867303829906},
 'fairness_indicators_metrics/negative_rate@0.3': {'doubleValue': 0.3924551561742503},
 'fairness_indicators_metrics/negative_rate@0.5': {'doubleValue': 0.6802950342821525},
 'fairness_indicators_metrics/negative_rate@0.7': {'doubleValue': 0.8735521850543666},
 'fairness_indicators_metrics/negative_rate@0.9': {'doubleValue': 0.9828381466860586},
 'fairness_indicators_metrics/positive_rate@0.1': {'doubleValue': 0.9255613269617009},
 'fairness_indicators_metrics/positive_rate@0.3': {'doubleValue': 0.6075448438257497},
 'fairness_indicators_metrics/positive_rate@0.5': {'doubleValue': 0.3197049657178475},
 'fairness_indicators_metrics/positive_rate@0.7': {'doubleValue': 0.12644781494563334},
 'fairness_indicators_metrics/positive_rate@0.9': {'doubleValue': 0.01716185331394141},
 'fairness_indicators_metrics/precision@0.1': {'doubleValue': 0.08610778962869402},
 'fairness_indicators_metrics/precision@0.3': {'doubleValue': 0.12053796364481997},
 'fairness_indicators_metrics/precision@0.5': {'doubleValue': 0.1833491471377014},
 'fairness_indicators_metrics/precision@0.7': {'doubleValue': 0.2906702888628422},
 'fairness_indicators_metrics/precision@0.9': {'doubleValue': 0.5154156577885391},
 'fairness_indicators_metrics/recall@0.1': {'doubleValue': 0.9938164985491226},
 'fairness_indicators_metrics/recall@0.3': {'doubleValue': 0.9131891667818157},
 'fairness_indicators_metrics/recall@0.5': {'doubleValue': 0.7309485974851457},
 'fairness_indicators_metrics/recall@0.7': {'doubleValue': 0.45832181843305236},
 'fairness_indicators_metrics/recall@0.9': {'doubleValue': 0.11030122979135},
 'fairness_indicators_metrics/true_negative_rate@0.1': {'doubleValue': 0.08038954663325573},
 'fairness_indicators_metrics/true_negative_rate@0.3': {'doubleValue': 0.4191029645179458},
 'fairness_indicators_metrics/true_negative_rate@0.5': {'doubleValue': 0.7161495902441669},
 'fairness_indicators_metrics/true_negative_rate@0.7': {'doubleValue': 0.9024868459492752},
 'fairness_indicators_metrics/true_negative_rate@0.9': {'doubleValue': 0.990958566622594},
 'fairness_indicators_metrics/true_positive_rate@0.1': {'doubleValue': 0.9938164985491226},
 'fairness_indicators_metrics/true_positive_rate@0.3': {'doubleValue': 0.9131891667818157},
 'fairness_indicators_metrics/true_positive_rate@0.5': {'doubleValue': 0.7309485974851457},
 'fairness_indicators_metrics/true_positive_rate@0.7': {'doubleValue': 0.45832181843305236},
 'fairness_indicators_metrics/true_positive_rate@0.9': {'doubleValue': 0.11030122979135},
 'label/mean': {'doubleValue': 0.08019392192363739},
 'post_export_metrics/example_count': {'doubleValue': 721950.0},
 'precision': {'doubleValue': 0.183349147439003},
 'prediction/mean': {'doubleValue': 0.3998327851295471},
 'recall': {'doubleValue': 0.7309486269950867} }

Heterosexual metric values:
{'accuracy': {'doubleValue': 0.5345528721809387},
 'accuracy_baseline': {'doubleValue': 0.7601625919342041},
 'auc': {'doubleValue': 0.6689590811729431},
 'auc_precision_recall': {'doubleValue': 0.40823081135749817},
 'average_loss': {'doubleValue': 0.8210510015487671},
 'fairness_indicators_metrics/false_discovery_rate@0.1': {'doubleValue': 0.7541666666666667},
 'fairness_indicators_metrics/false_discovery_rate@0.3': {'doubleValue': 0.7311557788944724},
 'fairness_indicators_metrics/false_discovery_rate@0.5': {'doubleValue': 0.696113074204947},
 'fairness_indicators_metrics/false_discovery_rate@0.7': {'doubleValue': 0.6514285714285715},
 'fairness_indicators_metrics/false_discovery_rate@0.9': {'doubleValue': 0.4},
 'fairness_indicators_metrics/false_negative_rate@0.1': {'doubleValue': 0.0},
 'fairness_indicators_metrics/false_negative_rate@0.3': {'doubleValue': 0.09322033898305085},
 'fairness_indicators_metrics/false_negative_rate@0.5': {'doubleValue': 0.2711864406779661},
 'fairness_indicators_metrics/false_negative_rate@0.7': {'doubleValue': 0.4830508474576271},
 'fairness_indicators_metrics/false_negative_rate@0.9': {'doubleValue': 0.8220338983050848},
 'fairness_indicators_metrics/false_omission_rate@0.1': {'doubleValue': 0.0},
 'fairness_indicators_metrics/false_omission_rate@0.3': {'doubleValue': 0.11702127659574468},
 'fairness_indicators_metrics/false_omission_rate@0.5': {'doubleValue': 0.15311004784688995},
 'fairness_indicators_metrics/false_omission_rate@0.7': {'doubleValue': 0.17981072555205047},
 'fairness_indicators_metrics/false_omission_rate@0.9': {'doubleValue': 0.212253829321663},
 'fairness_indicators_metrics/false_positive_rate@0.1': {'doubleValue': 0.9679144385026738},
 'fairness_indicators_metrics/false_positive_rate@0.3': {'doubleValue': 0.7780748663101604},
 'fairness_indicators_metrics/false_positive_rate@0.5': {'doubleValue': 0.5267379679144385},
 'fairness_indicators_metrics/false_positive_rate@0.7': {'doubleValue': 0.3048128342245989},
 'fairness_indicators_metrics/false_positive_rate@0.9': {'doubleValue': 0.0374331550802139},
 'fairness_indicators_metrics/negative_rate@0.1': {'doubleValue': 0.024390243902439025},
 'fairness_indicators_metrics/negative_rate@0.3': {'doubleValue': 0.1910569105691057},
 'fairness_indicators_metrics/negative_rate@0.5': {'doubleValue': 0.4247967479674797},
 'fairness_indicators_metrics/negative_rate@0.7': {'doubleValue': 0.6443089430894309},
 'fairness_indicators_metrics/negative_rate@0.9': {'doubleValue': 0.9288617886178862},
 'fairness_indicators_metrics/positive_rate@0.1': {'doubleValue': 0.975609756097561},
 'fairness_indicators_metrics/positive_rate@0.3': {'doubleValue': 0.8089430894308943},
 'fairness_indicators_metrics/positive_rate@0.5': {'doubleValue': 0.5752032520325203},
 'fairness_indicators_metrics/positive_rate@0.7': {'doubleValue': 0.3556910569105691},
 'fairness_indicators_metrics/positive_rate@0.9': {'doubleValue': 0.07113821138211382},
 'fairness_indicators_metrics/precision@0.1': {'doubleValue': 0.24583333333333332},
 'fairness_indicators_metrics/precision@0.3': {'doubleValue': 0.26884422110552764},
 'fairness_indicators_metrics/precision@0.5': {'doubleValue': 0.303886925795053},
 'fairness_indicators_metrics/precision@0.7': {'doubleValue': 0.3485714285714286},
 'fairness_indicators_metrics/precision@0.9': {'doubleValue': 0.6},
 'fairness_indicators_metrics/recall@0.1': {'doubleValue': 1.0},
 'fairness_indicators_metrics/recall@0.3': {'doubleValue': 0.9067796610169492},
 'fairness_indicators_metrics/recall@0.5': {'doubleValue': 0.7288135593220338},
 'fairness_indicators_metrics/recall@0.7': {'doubleValue': 0.5169491525423728},
 'fairness_indicators_metrics/recall@0.9': {'doubleValue': 0.17796610169491525},
 'fairness_indicators_metrics/true_negative_rate@0.1': {'doubleValue': 0.03208556149732621},
 'fairness_indicators_metrics/true_negative_rate@0.3': {'doubleValue': 0.22192513368983957},
 'fairness_indicators_metrics/true_negative_rate@0.5': {'doubleValue': 0.4732620320855615},
 'fairness_indicators_metrics/true_negative_rate@0.7': {'doubleValue': 0.6951871657754011},
 'fairness_indicators_metrics/true_negative_rate@0.9': {'doubleValue': 0.9625668449197861},
 'fairness_indicators_metrics/true_positive_rate@0.1': {'doubleValue': 1.0},
 'fairness_indicators_metrics/true_positive_rate@0.3': {'doubleValue': 0.9067796610169492},
 'fairness_indicators_metrics/true_positive_rate@0.5': {'doubleValue': 0.7288135593220338},
 'fairness_indicators_metrics/true_positive_rate@0.7': {'doubleValue': 0.5169491525423728},
 'fairness_indicators_metrics/true_positive_rate@0.9': {'doubleValue': 0.17796610169491525},
 'label/mean': {'doubleValue': 0.2398373931646347},
 'post_export_metrics/example_count': {'doubleValue': 492.0},
 'precision': {'doubleValue': 0.30388692021369934},
 'prediction/mean': {'doubleValue': 0.5556126832962036},
 'recall': {'doubleValue': 0.7288135886192322} }

Use get_metrics_for_all_slices() to get the metrics for all slices as a dictionary mapping each slice to the corresponding metrics dictionary you obtain from running get_metrics_for_slice() on it.

pp.pprint(eval_result.get_metrics_for_all_slices())
{(): {'accuracy': {'doubleValue': 0.7173363566398621},
      'accuracy_baseline': {'doubleValue': 0.9198060631752014},
      'auc': {'doubleValue': 0.7970057725906372},
      'auc_precision_recall': {'doubleValue': 0.30066317319869995},
      'average_loss': {'doubleValue': 0.5619063377380371},
      'fairness_indicators_metrics/false_discovery_rate@0.1': {'doubleValue': 0.913892210371306},
      'fairness_indicators_metrics/false_discovery_rate@0.3': {'doubleValue': 0.87946203635518},
      'fairness_indicators_metrics/false_discovery_rate@0.5': {'doubleValue': 0.8166508528622985},
      'fairness_indicators_metrics/false_discovery_rate@0.7': {'doubleValue': 0.7093297111371578},
      'fairness_indicators_metrics/false_discovery_rate@0.9': {'doubleValue': 0.48458434221146085},
      'fairness_indicators_metrics/false_negative_rate@0.1': {'doubleValue': 0.006183501450877435},
      'fairness_indicators_metrics/false_negative_rate@0.3': {'doubleValue': 0.08681083321818434},
      'fairness_indicators_metrics/false_negative_rate@0.5': {'doubleValue': 0.2690514025148542},
      'fairness_indicators_metrics/false_negative_rate@0.7': {'doubleValue': 0.5416781815669476},
      'fairness_indicators_metrics/false_negative_rate@0.9': {'doubleValue': 0.88969877020865},
      'fairness_indicators_metrics/false_omission_rate@0.1': {'doubleValue': 0.006661580543718949},
      'fairness_indicators_metrics/false_omission_rate@0.3': {'doubleValue': 0.017738844398640468},
      'fairness_indicators_metrics/false_omission_rate@0.5': {'doubleValue': 0.03171607223209723},
      'fairness_indicators_metrics/false_omission_rate@0.7': {'doubleValue': 0.04972719099484509},
      'fairness_indicators_metrics/false_omission_rate@0.9': {'doubleValue': 0.07259428378149839},
      'fairness_indicators_metrics/false_positive_rate@0.1': {'doubleValue': 0.9196104533667443},
      'fairness_indicators_metrics/false_positive_rate@0.3': {'doubleValue': 0.5808970354820542},
      'fairness_indicators_metrics/false_positive_rate@0.5': {'doubleValue': 0.2838504097558331},
      'fairness_indicators_metrics/false_positive_rate@0.7': {'doubleValue': 0.09751315405072479},
      'fairness_indicators_metrics/false_positive_rate@0.9': {'doubleValue': 0.009041433377406054},
      'fairness_indicators_metrics/negative_rate@0.1': {'doubleValue': 0.07443867303829906},
      'fairness_indicators_metrics/negative_rate@0.3': {'doubleValue': 0.3924551561742503},
      'fairness_indicators_metrics/negative_rate@0.5': {'doubleValue': 0.6802950342821525},
      'fairness_indicators_metrics/negative_rate@0.7': {'doubleValue': 0.8735521850543666},
      'fairness_indicators_metrics/negative_rate@0.9': {'doubleValue': 0.9828381466860586},
      'fairness_indicators_metrics/positive_rate@0.1': {'doubleValue': 0.9255613269617009},
      'fairness_indicators_metrics/positive_rate@0.3': {'doubleValue': 0.6075448438257497},
      'fairness_indicators_metrics/positive_rate@0.5': {'doubleValue': 0.3197049657178475},
      'fairness_indicators_metrics/positive_rate@0.7': {'doubleValue': 0.12644781494563334},
      'fairness_indicators_metrics/positive_rate@0.9': {'doubleValue': 0.01716185331394141},
      'fairness_indicators_metrics/precision@0.1': {'doubleValue': 0.08610778962869402},
      'fairness_indicators_metrics/precision@0.3': {'doubleValue': 0.12053796364481997},
      'fairness_indicators_metrics/precision@0.5': {'doubleValue': 0.1833491471377014},
      'fairness_indicators_metrics/precision@0.7': {'doubleValue': 0.2906702888628422},
      'fairness_indicators_metrics/precision@0.9': {'doubleValue': 0.5154156577885391},
      'fairness_indicators_metrics/recall@0.1': {'doubleValue': 0.9938164985491226},
      'fairness_indicators_metrics/recall@0.3': {'doubleValue': 0.9131891667818157},
      'fairness_indicators_metrics/recall@0.5': {'doubleValue': 0.7309485974851457},
      'fairness_indicators_metrics/recall@0.7': {'doubleValue': 0.45832181843305236},
      'fairness_indicators_metrics/recall@0.9': {'doubleValue': 0.11030122979135},
      'fairness_indicators_metrics/true_negative_rate@0.1': {'doubleValue': 0.08038954663325573},
      'fairness_indicators_metrics/true_negative_rate@0.3': {'doubleValue': 0.4191029645179458},
      'fairness_indicators_metrics/true_negative_rate@0.5': {'doubleValue': 0.7161495902441669},
      'fairness_indicators_metrics/true_negative_rate@0.7': {'doubleValue': 0.9024868459492752},
      'fairness_indicators_metrics/true_negative_rate@0.9': {'doubleValue': 0.990958566622594},
      'fairness_indicators_metrics/true_positive_rate@0.1': {'doubleValue': 0.9938164985491226},
      'fairness_indicators_metrics/true_positive_rate@0.3': {'doubleValue': 0.9131891667818157},
      'fairness_indicators_metrics/true_positive_rate@0.5': {'doubleValue': 0.7309485974851457},
      'fairness_indicators_metrics/true_positive_rate@0.7': {'doubleValue': 0.45832181843305236},
      'fairness_indicators_metrics/true_positive_rate@0.9': {'doubleValue': 0.11030122979135},
      'label/mean': {'doubleValue': 0.08019392192363739},
      'post_export_metrics/example_count': {'doubleValue': 721950.0},
      'precision': {'doubleValue': 0.183349147439003},
      'prediction/mean': {'doubleValue': 0.3998327851295471},
      'recall': {'doubleValue': 0.7309486269950867} },
 (('sexual_orientation', 'bisexual'),): {'accuracy': {'doubleValue': 0.5258620977401733},
                                         'accuracy_baseline': {'doubleValue': 0.8017241358757019},
                                         'auc': {'doubleValue': 0.6278634667396545},
                                         'auc_precision_recall': {'doubleValue': 0.33900630474090576},
                                         'average_loss': {'doubleValue': 0.7456364035606384},
                                         'fairness_indicators_metrics/false_discovery_rate@0.1': {'doubleValue': 0.7870370370370371},
                                         'fairness_indicators_metrics/false_discovery_rate@0.3': {'doubleValue': 0.7816091954022989},
                                         'fairness_indicators_metrics/false_discovery_rate@0.5': {'doubleValue': 0.7666666666666667},
                                         'fairness_indicators_metrics/false_discovery_rate@0.7': {'doubleValue': 0.7142857142857143},
                                         'fairness_indicators_metrics/false_discovery_rate@0.9': {'doubleValue': 0.0},
                                         'fairness_indicators_metrics/false_negative_rate@0.1': {'doubleValue': 0.0},
                                         'fairness_indicators_metrics/false_negative_rate@0.3': {'doubleValue': 0.17391304347826086},
                                         'fairness_indicators_metrics/false_negative_rate@0.5': {'doubleValue': 0.391304347826087},
                                         'fairness_indicators_metrics/false_negative_rate@0.7': {'doubleValue': 0.6521739130434783},
                                         'fairness_indicators_metrics/false_negative_rate@0.9': {'doubleValue': 0.9565217391304348},
                                         'fairness_indicators_metrics/false_omission_rate@0.1': {'doubleValue': 0.0},
                                         'fairness_indicators_metrics/false_omission_rate@0.3': {'doubleValue': 0.13793103448275862},
                                         'fairness_indicators_metrics/false_omission_rate@0.5': {'doubleValue': 0.16071428571428573},
                                         'fairness_indicators_metrics/false_omission_rate@0.7': {'doubleValue': 0.17045454545454544},
                                         'fairness_indicators_metrics/false_omission_rate@0.9': {'doubleValue': 0.19130434782608696},
                                         'fairness_indicators_metrics/false_positive_rate@0.1': {'doubleValue': 0.9139784946236559},
                                         'fairness_indicators_metrics/false_positive_rate@0.3': {'doubleValue': 0.7311827956989247},
                                         'fairness_indicators_metrics/false_positive_rate@0.5': {'doubleValue': 0.4946236559139785},
                                         'fairness_indicators_metrics/false_positive_rate@0.7': {'doubleValue': 0.21505376344086022},
                                         'fairness_indicators_metrics/false_positive_rate@0.9': {'doubleValue': 0.0},
                                         'fairness_indicators_metrics/negative_rate@0.1': {'doubleValue': 0.06896551724137931},
                                         'fairness_indicators_metrics/negative_rate@0.3': {'doubleValue': 0.25},
                                         'fairness_indicators_metrics/negative_rate@0.5': {'doubleValue': 0.4827586206896552},
                                         'fairness_indicators_metrics/negative_rate@0.7': {'doubleValue': 0.7586206896551724},
                                         'fairness_indicators_metrics/negative_rate@0.9': {'doubleValue': 0.9913793103448276},
                                         'fairness_indicators_metrics/positive_rate@0.1': {'doubleValue': 0.9310344827586207},
                                         'fairness_indicators_metrics/positive_rate@0.3': {'doubleValue': 0.75},
                                         'fairness_indicators_metrics/positive_rate@0.5': {'doubleValue': 0.5172413793103449},
                                         'fairness_indicators_metrics/positive_rate@0.7': {'doubleValue': 0.2413793103448276},
                                         'fairness_indicators_metrics/positive_rate@0.9': {'doubleValue': 0.008620689655172414},
                                         'fairness_indicators_metrics/precision@0.1': {'doubleValue': 0.21296296296296297},
                                         'fairness_indicators_metrics/precision@0.3': {'doubleValue': 0.21839080459770116},
                                         'fairness_indicators_metrics/precision@0.5': {'doubleValue': 0.23333333333333334},
                                         'fairness_indicators_metrics/precision@0.7': {'doubleValue': 0.2857142857142857},
                                         'fairness_indicators_metrics/precision@0.9': {'doubleValue': 1.0},
                                         'fairness_indicators_metrics/recall@0.1': {'doubleValue': 1.0},
                                         'fairness_indicators_metrics/recall@0.3': {'doubleValue': 0.8260869565217391},
                                         'fairness_indicators_metrics/recall@0.5': {'doubleValue': 0.6086956521739131},
                                         'fairness_indicators_metrics/recall@0.7': {'doubleValue': 0.34782608695652173},
                                         'fairness_indicators_metrics/recall@0.9': {'doubleValue': 0.043478260869565216},
                                         'fairness_indicators_metrics/true_negative_rate@0.1': {'doubleValue': 0.08602150537634409},
                                         'fairness_indicators_metrics/true_negative_rate@0.3': {'doubleValue': 0.26881720430107525},
                                         'fairness_indicators_metrics/true_negative_rate@0.5': {'doubleValue': 0.5053763440860215},
                                         'fairness_indicators_metrics/true_negative_rate@0.7': {'doubleValue': 0.7849462365591398},
                                         'fairness_indicators_metrics/true_negative_rate@0.9': {'doubleValue': 1.0},
                                         'fairness_indicators_metrics/true_positive_rate@0.1': {'doubleValue': 1.0},
                                         'fairness_indicators_metrics/true_positive_rate@0.3': {'doubleValue': 0.8260869565217391},
                                         'fairness_indicators_metrics/true_positive_rate@0.5': {'doubleValue': 0.6086956521739131},
                                         'fairness_indicators_metrics/true_positive_rate@0.7': {'doubleValue': 0.34782608695652173},
                                         'fairness_indicators_metrics/true_positive_rate@0.9': {'doubleValue': 0.043478260869565216},
                                         'label/mean': {'doubleValue': 0.1982758641242981},
                                         'post_export_metrics/example_count': {'doubleValue': 116.0},
                                         'precision': {'doubleValue': 0.23333333432674408},
                                         'prediction/mean': {'doubleValue': 0.4923667311668396},
                                         'recall': {'doubleValue': 0.6086956262588501} },
 (('sexual_orientation', 'heterosexual'),): {'accuracy': {'doubleValue': 0.5345528721809387},
                                             'accuracy_baseline': {'doubleValue': 0.7601625919342041},
                                             'auc': {'doubleValue': 0.6689590811729431},
                                             'auc_precision_recall': {'doubleValue': 0.40823081135749817},
                                             'average_loss': {'doubleValue': 0.8210510015487671},
                                             'fairness_indicators_metrics/false_discovery_rate@0.1': {'doubleValue': 0.7541666666666667},
                                             'fairness_indicators_metrics/false_discovery_rate@0.3': {'doubleValue': 0.7311557788944724},
                                             'fairness_indicators_metrics/false_discovery_rate@0.5': {'doubleValue': 0.696113074204947},
                                             'fairness_indicators_metrics/false_discovery_rate@0.7': {'doubleValue': 0.6514285714285715},
                                             'fairness_indicators_metrics/false_discovery_rate@0.9': {'doubleValue': 0.4},
                                             'fairness_indicators_metrics/false_negative_rate@0.1': {'doubleValue': 0.0},
                                             'fairness_indicators_metrics/false_negative_rate@0.3': {'doubleValue': 0.09322033898305085},
                                             'fairness_indicators_metrics/false_negative_rate@0.5': {'doubleValue': 0.2711864406779661},
                                             'fairness_indicators_metrics/false_negative_rate@0.7': {'doubleValue': 0.4830508474576271},
                                             'fairness_indicators_metrics/false_negative_rate@0.9': {'doubleValue': 0.8220338983050848},
                                             'fairness_indicators_metrics/false_omission_rate@0.1': {'doubleValue': 0.0},
                                             'fairness_indicators_metrics/false_omission_rate@0.3': {'doubleValue': 0.11702127659574468},
                                             'fairness_indicators_metrics/false_omission_rate@0.5': {'doubleValue': 0.15311004784688995},
                                             'fairness_indicators_metrics/false_omission_rate@0.7': {'doubleValue': 0.17981072555205047},
                                             'fairness_indicators_metrics/false_omission_rate@0.9': {'doubleValue': 0.212253829321663},
                                             'fairness_indicators_metrics/false_positive_rate@0.1': {'doubleValue': 0.9679144385026738},
                                             'fairness_indicators_metrics/false_positive_rate@0.3': {'doubleValue': 0.7780748663101604},
                                             'fairness_indicators_metrics/false_positive_rate@0.5': {'doubleValue': 0.5267379679144385},
                                             'fairness_indicators_metrics/false_positive_rate@0.7': {'doubleValue': 0.3048128342245989},
                                             'fairness_indicators_metrics/false_positive_rate@0.9': {'doubleValue': 0.0374331550802139},
                                             'fairness_indicators_metrics/negative_rate@0.1': {'doubleValue': 0.024390243902439025},
                                             'fairness_indicators_metrics/negative_rate@0.3': {'doubleValue': 0.1910569105691057},
                                             'fairness_indicators_metrics/negative_rate@0.5': {'doubleValue': 0.4247967479674797},
                                             'fairness_indicators_metrics/negative_rate@0.7': {'doubleValue': 0.6443089430894309},
                                             'fairness_indicators_metrics/negative_rate@0.9': {'doubleValue': 0.9288617886178862},
                                             'fairness_indicators_metrics/positive_rate@0.1': {'doubleValue': 0.975609756097561},
                                             'fairness_indicators_metrics/positive_rate@0.3': {'doubleValue': 0.8089430894308943},
                                             'fairness_indicators_metrics/positive_rate@0.5': {'doubleValue': 0.5752032520325203},
                                             'fairness_indicators_metrics/positive_rate@0.7': {'doubleValue': 0.3556910569105691},
                                             'fairness_indicators_metrics/positive_rate@0.9': {'doubleValue': 0.07113821138211382},
                                             'fairness_indicators_metrics/precision@0.1': {'doubleValue': 0.24583333333333332},
                                             'fairness_indicators_metrics/precision@0.3': {'doubleValue': 0.26884422110552764},
                                             'fairness_indicators_metrics/precision@0.5': {'doubleValue': 0.303886925795053},
                                             'fairness_indicators_metrics/precision@0.7': {'doubleValue': 0.3485714285714286},
                                             'fairness_indicators_metrics/precision@0.9': {'doubleValue': 0.6},
                                             'fairness_indicators_metrics/recall@0.1': {'doubleValue': 1.0},
                                             'fairness_indicators_metrics/recall@0.3': {'doubleValue': 0.9067796610169492},
                                             'fairness_indicators_metrics/recall@0.5': {'doubleValue': 0.7288135593220338},
                                             'fairness_indicators_metrics/recall@0.7': {'doubleValue': 0.5169491525423728},
                                             'fairness_indicators_metrics/recall@0.9': {'doubleValue': 0.17796610169491525},
                                             'fairness_indicators_metrics/true_negative_rate@0.1': {'doubleValue': 0.03208556149732621},
                                             'fairness_indicators_metrics/true_negative_rate@0.3': {'doubleValue': 0.22192513368983957},
                                             'fairness_indicators_metrics/true_negative_rate@0.5': {'doubleValue': 0.4732620320855615},
                                             'fairness_indicators_metrics/true_negative_rate@0.7': {'doubleValue': 0.6951871657754011},
                                             'fairness_indicators_metrics/true_negative_rate@0.9': {'doubleValue': 0.9625668449197861},
                                             'fairness_indicators_metrics/true_positive_rate@0.1': {'doubleValue': 1.0},
                                             'fairness_indicators_metrics/true_positive_rate@0.3': {'doubleValue': 0.9067796610169492},
                                             'fairness_indicators_metrics/true_positive_rate@0.5': {'doubleValue': 0.7288135593220338},
                                             'fairness_indicators_metrics/true_positive_rate@0.7': {'doubleValue': 0.5169491525423728},
                                             'fairness_indicators_metrics/true_positive_rate@0.9': {'doubleValue': 0.17796610169491525},
                                             'label/mean': {'doubleValue': 0.2398373931646347},
                                             'post_export_metrics/example_count': {'doubleValue': 492.0},
                                             'precision': {'doubleValue': 0.30388692021369934},
                                             'prediction/mean': {'doubleValue': 0.5556126832962036},
                                             'recall': {'doubleValue': 0.7288135886192322} },
 (('sexual_orientation', 'homosexual_gay_or_lesbian'),): {'accuracy': {'doubleValue': 0.5851936340332031},
                                                          'accuracy_baseline': {'doubleValue': 0.7182232141494751},
                                                          'auc': {'doubleValue': 0.7075940370559692},
                                                          'auc_precision_recall': {'doubleValue': 0.47235822677612305},
                                                          'average_loss': {'doubleValue': 0.7364749312400818},
                                                          'fairness_indicators_metrics/false_discovery_rate@0.1': {'doubleValue': 0.7107728337236534},
                                                          'fairness_indicators_metrics/false_discovery_rate@0.3': {'doubleValue': 0.6723259762308998},
                                                          'fairness_indicators_metrics/false_discovery_rate@0.5': {'doubleValue': 0.6170809943865276},
                                                          'fairness_indicators_metrics/false_discovery_rate@0.7': {'doubleValue': 0.5445255474452555},
                                                          'fairness_indicators_metrics/false_discovery_rate@0.9': {'doubleValue': 0.40601503759398494},
                                                          'fairness_indicators_metrics/false_negative_rate@0.1': {'doubleValue': 0.0016168148746968471},
                                                          'fairness_indicators_metrics/false_negative_rate@0.3': {'doubleValue': 0.06386418755052546},
                                                          'fairness_indicators_metrics/false_negative_rate@0.5': {'doubleValue': 0.22797089733225545},
                                                          'fairness_indicators_metrics/false_negative_rate@0.7': {'doubleValue': 0.49555375909458366},
                                                          'fairness_indicators_metrics/false_negative_rate@0.9': {'doubleValue': 0.872271624898949},
                                                          'fairness_indicators_metrics/false_omission_rate@0.1': {'doubleValue': 0.016666666666666666},
                                                          'fairness_indicators_metrics/false_omission_rate@0.3': {'doubleValue': 0.09228971962616822},
                                                          'fairness_indicators_metrics/false_omission_rate@0.5': {'doubleValue': 0.14873417721518986},
                                                          'fairness_indicators_metrics/false_omission_rate@0.7': {'doubleValue': 0.2029801324503311},
                                                          'fairness_indicators_metrics/false_omission_rate@0.9': {'doubleValue': 0.261639185257032},
                                                          'fairness_indicators_metrics/false_positive_rate@0.1': {'doubleValue': 0.9625753250872185},
                                                          'fairness_indicators_metrics/false_positive_rate@0.3': {'doubleValue': 0.7535680304471931},
                                                          'fairness_indicators_metrics/false_positive_rate@0.5': {'doubleValue': 0.48810656517602286},
                                                          'fairness_indicators_metrics/false_positive_rate@0.7': {'doubleValue': 0.2366000634316524},
                                                          'fairness_indicators_metrics/false_positive_rate@0.9': {'doubleValue': 0.03425309229305423},
                                                          'fairness_indicators_metrics/negative_rate@0.1': {'doubleValue': 0.02733485193621868},
                                                          'fairness_indicators_metrics/negative_rate@0.3': {'doubleValue': 0.19498861047835991},
                                                          'fairness_indicators_metrics/negative_rate@0.5': {'doubleValue': 0.4318906605922551},
                                                          'fairness_indicators_metrics/negative_rate@0.7': {'doubleValue': 0.6879271070615034},
                                                          'fairness_indicators_metrics/negative_rate@0.9': {'doubleValue': 0.9394077448747152},
                                                          'fairness_indicators_metrics/positive_rate@0.1': {'doubleValue': 0.9726651480637813},
                                                          'fairness_indicators_metrics/positive_rate@0.3': {'doubleValue': 0.8050113895216401},
                                                          'fairness_indicators_metrics/positive_rate@0.5': {'doubleValue': 0.5681093394077449},
                                                          'fairness_indicators_metrics/positive_rate@0.7': {'doubleValue': 0.3120728929384966},
                                                          'fairness_indicators_metrics/positive_rate@0.9': {'doubleValue': 0.06059225512528474},
                                                          'fairness_indicators_metrics/precision@0.1': {'doubleValue': 0.2892271662763466},
                                                          'fairness_indicators_metrics/precision@0.3': {'doubleValue': 0.32767402376910015},
                                                          'fairness_indicators_metrics/precision@0.5': {'doubleValue': 0.3829190056134723},
                                                          'fairness_indicators_metrics/precision@0.7': {'doubleValue': 0.4554744525547445},
                                                          'fairness_indicators_metrics/precision@0.9': {'doubleValue': 0.5939849624060151},
                                                          'fairness_indicators_metrics/recall@0.1': {'doubleValue': 0.9983831851253031},
                                                          'fairness_indicators_metrics/recall@0.3': {'doubleValue': 0.9361358124494745},
                                                          'fairness_indicators_metrics/recall@0.5': {'doubleValue': 0.7720291026677445},
                                                          'fairness_indicators_metrics/recall@0.7': {'doubleValue': 0.5044462409054163},
                                                          'fairness_indicators_metrics/recall@0.9': {'doubleValue': 0.12772837510105092},
                                                          'fairness_indicators_metrics/true_negative_rate@0.1': {'doubleValue': 0.03742467491278148},
                                                          'fairness_indicators_metrics/true_negative_rate@0.3': {'doubleValue': 0.24643196955280686},
                                                          'fairness_indicators_metrics/true_negative_rate@0.5': {'doubleValue': 0.5118934348239772},
                                                          'fairness_indicators_metrics/true_negative_rate@0.7': {'doubleValue': 0.7633999365683476},
                                                          'fairness_indicators_metrics/true_negative_rate@0.9': {'doubleValue': 0.9657469077069457},
                                                          'fairness_indicators_metrics/true_positive_rate@0.1': {'doubleValue': 0.9983831851253031},
                                                          'fairness_indicators_metrics/true_positive_rate@0.3': {'doubleValue': 0.9361358124494745},
                                                          'fairness_indicators_metrics/true_positive_rate@0.5': {'doubleValue': 0.7720291026677445},
                                                          'fairness_indicators_metrics/true_positive_rate@0.7': {'doubleValue': 0.5044462409054163},
                                                          'fairness_indicators_metrics/true_positive_rate@0.9': {'doubleValue': 0.12772837510105092},
                                                          'label/mean': {'doubleValue': 0.2817767560482025},
                                                          'post_export_metrics/example_count': {'doubleValue': 4390.0},
                                                          'precision': {'doubleValue': 0.3829190135002136},
                                                          'prediction/mean': {'doubleValue': 0.5433647632598877},
                                                          'recall': {'doubleValue': 0.7720291018486023} },
 (('sexual_orientation', 'other_sexual_orientation'),): {'accuracy': {'doubleValue': 0.6000000238418579},
                                                         'accuracy_baseline': {'doubleValue': 0.800000011920929},
                                                         'auc': {'doubleValue': 1.0},
                                                         'auc_precision_recall': {'doubleValue': 1.0},
                                                         'average_loss': {'doubleValue': 0.7615415453910828},
                                                         'fairness_indicators_metrics/false_discovery_rate@0.1': {'doubleValue': 0.8},
                                                         'fairness_indicators_metrics/false_discovery_rate@0.3': {'doubleValue': 0.75},
                                                         'fairness_indicators_metrics/false_discovery_rate@0.5': {'doubleValue': 0.6666666666666666},
                                                         'fairness_indicators_metrics/false_discovery_rate@0.7': {'doubleValue': 0.5},
                                                         'fairness_indicators_metrics/false_discovery_rate@0.9': {'doubleValue': 'NaN'},
                                                         'fairness_indicators_metrics/false_negative_rate@0.1': {'doubleValue': 0.0},
                                                         'fairness_indicators_metrics/false_negative_rate@0.3': {'doubleValue': 0.0},
                                                         'fairness_indicators_metrics/false_negative_rate@0.5': {'doubleValue': 0.0},
                                                         'fairness_indicators_metrics/false_negative_rate@0.7': {'doubleValue': 0.0},
                                                         'fairness_indicators_metrics/false_negative_rate@0.9': {'doubleValue': 1.0},
                                                         'fairness_indicators_metrics/false_omission_rate@0.1': {'doubleValue': 'NaN'},
                                                         'fairness_indicators_metrics/false_omission_rate@0.3': {'doubleValue': 0.0},
                                                         'fairness_indicators_metrics/false_omission_rate@0.5': {'doubleValue': 0.0},
                                                         'fairness_indicators_metrics/false_omission_rate@0.7': {'doubleValue': 0.0},
                                                         'fairness_indicators_metrics/false_omission_rate@0.9': {'doubleValue': 0.2},
                                                         'fairness_indicators_metrics/false_positive_rate@0.1': {'doubleValue': 1.0},
                                                         'fairness_indicators_metrics/false_positive_rate@0.3': {'doubleValue': 0.75},
                                                         'fairness_indicators_metrics/false_positive_rate@0.5': {'doubleValue': 0.5},
                                                         'fairness_indicators_metrics/false_positive_rate@0.7': {'doubleValue': 0.25},
                                                         'fairness_indicators_metrics/false_positive_rate@0.9': {'doubleValue': 0.0},
                                                         'fairness_indicators_metrics/negative_rate@0.1': {'doubleValue': 0.0},
                                                         'fairness_indicators_metrics/negative_rate@0.3': {'doubleValue': 0.2},
                                                         'fairness_indicators_metrics/negative_rate@0.5': {'doubleValue': 0.4},
                                                         'fairness_indicators_metrics/negative_rate@0.7': {'doubleValue': 0.6},
                                                         'fairness_indicators_metrics/negative_rate@0.9': {'doubleValue': 1.0},
                                                         'fairness_indicators_metrics/positive_rate@0.1': {'doubleValue': 1.0},
                                                         'fairness_indicators_metrics/positive_rate@0.3': {'doubleValue': 0.8},
                                                         'fairness_indicators_metrics/positive_rate@0.5': {'doubleValue': 0.6},
                                                         'fairness_indicators_metrics/positive_rate@0.7': {'doubleValue': 0.4},
                                                         'fairness_indicators_metrics/positive_rate@0.9': {'doubleValue': 0.0},
                                                         'fairness_indicators_metrics/precision@0.1': {'doubleValue': 0.2},
                                                         'fairness_indicators_metrics/precision@0.3': {'doubleValue': 0.25},
                                                         'fairness_indicators_metrics/precision@0.5': {'doubleValue': 0.3333333333333333},
                                                         'fairness_indicators_metrics/precision@0.7': {'doubleValue': 0.5},
                                                         'fairness_indicators_metrics/precision@0.9': {'doubleValue': 'NaN'},
                                                         'fairness_indicators_metrics/recall@0.1': {'doubleValue': 1.0},
                                                         'fairness_indicators_metrics/recall@0.3': {'doubleValue': 1.0},
                                                         'fairness_indicators_metrics/recall@0.5': {'doubleValue': 1.0},
                                                         'fairness_indicators_metrics/recall@0.7': {'doubleValue': 1.0},
                                                         'fairness_indicators_metrics/recall@0.9': {'doubleValue': 0.0},
                                                         'fairness_indicators_metrics/true_negative_rate@0.1': {'doubleValue': 0.0},
                                                         'fairness_indicators_metrics/true_negative_rate@0.3': {'doubleValue': 0.25},
                                                         'fairness_indicators_metrics/true_negative_rate@0.5': {'doubleValue': 0.5},
                                                         'fairness_indicators_metrics/true_negative_rate@0.7': {'doubleValue': 0.75},
                                                         'fairness_indicators_metrics/true_negative_rate@0.9': {'doubleValue': 1.0},
                                                         'fairness_indicators_metrics/true_positive_rate@0.1': {'doubleValue': 1.0},
                                                         'fairness_indicators_metrics/true_positive_rate@0.3': {'doubleValue': 1.0},
                                                         'fairness_indicators_metrics/true_positive_rate@0.5': {'doubleValue': 1.0},
                                                         'fairness_indicators_metrics/true_positive_rate@0.7': {'doubleValue': 1.0},
                                                         'fairness_indicators_metrics/true_positive_rate@0.9': {'doubleValue': 0.0},
                                                         'label/mean': {'doubleValue': 0.20000000298023224},
                                                         'post_export_metrics/example_count': {'doubleValue': 5.0},
                                                         'precision': {'doubleValue': 0.3333333432674408},
                                                         'prediction/mean': {'doubleValue': 0.6053622961044312},
                                                         'recall': {'doubleValue': 1.0} } }