System information
- Have I written custom code (as opposed to using a stock example script
provided in TensorFlow Model Analysis): Yes
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Chromium OS 12.0_pre408248_p20201125-r7
- TensorFlow Model Analysis installed from (source or binary): binary
- TensorFlow Model Analysis version (use command below): 0.26
- Python version: 3.7.9
- Jupyter Notebook version: 6.1.3
- Exact command to reproduce:
First method using TFX
import tensorflow_model_analysis as tfma
from tfx.components import Evaluator
eval_config = tfma.EvalConfig(
model_specs=[
tfma.ModelSpec(label_key='toxicity', signature_name='serve_tfexample')
],
metrics_specs=[
tfma.MetricsSpec(
metrics=[
tfma.MetricConfig(class_name='ExampleCount'),
tfma.MetricConfig(class_name='BinaryAccuracy')
]
)
],
slicing_specs=[
tfma.SlicingSpec(),
tfma.SlicingSpec(feature_keys=['race']),
]
)
evaluator = Evaluator(
examples=example_gen.outputs['examples'],
schema=schema_gen.outputs['schema'],
model=trainer.outputs['model'],
fairness_indicator_thresholds=[0.3, 0.5, 0.7],
eval_config=eval_config,
)
context.run(evaluator)
eval_result_uri = evaluator.outputs['evaluation'].get()[0].uri
eval_result = tfma.load_eval_result(eval_result_uri)
from tensorflow_model_analysis.addons.fairness.view import widget_view
widget_view.render_fairness_indicator(eval_result=eval_result)
Second method without TFX
tfma_eval_result_path = './bert/tfma_eval_result'
import tensorflow_model_analysis.addons.fairness.post_export_metrics.fairness_indicators
from google.protobuf import text_format
metrics_callbacks = [
tfma.post_export_metrics.fairness_indicators(thresholds=[0.3, 0.5, 0.7]),
]
eval_config = tfma.EvalConfig(
model_specs=[
tfma.ModelSpec(label_key=LABEL)
],
metrics_specs=[
tfma.MetricsSpec(
metrics=[
tfma.MetricConfig(class_name='ExampleCount'),
tfma.MetricConfig(class_name='BinaryAccuracy')
]
)
],
slicing_specs=[
# An empty slice spec means the overall slice, i.e. the whole dataset.
tfma.SlicingSpec(),
tfma.SlicingSpec(feature_keys=['race']),
]
)
eval_shared_model = tfma.default_eval_shared_model(
eval_saved_model_path='./checkpoints',
add_metrics_callbacks=metrics_callbacks,
eval_config=eval_config)
eval_result = tfma.run_model_analysis(
eval_config=eval_config,
eval_shared_model=eval_shared_model,
data_location=validate_tf_file,
output_path=tfma_eval_result_path)
from tensorflow_model_analysis.addons.fairness.view import widget_view
widget_view.render_fairness_indicator(eval_result=eval_result)
Describe the problem
I am trying to display fairness metrics with a TF2 based model, but for some reason, the fairness metrics (false discovery rate, false positive rate, etc.) do not show up in eval_result or in the fairness indicator widget (see screenshot below). This happened both when I use TFX's Evaluator component and when I run TFMA directly. Is it a bug or am I doing something wrong?

System information
provided in TensorFlow Model Analysis): Yes
First method using TFX
Second method without TFX
Describe the problem
I am trying to display fairness metrics with a TF2 based model, but for some reason, the fairness metrics (false discovery rate, false positive rate, etc.) do not show up in eval_result or in the fairness indicator widget (see screenshot below). This happened both when I use TFX's Evaluator component and when I run TFMA directly. Is it a bug or am I doing something wrong?