in fairness_indicators/remediation/weight_utils.py [0:0]
def get_baseline_value(
eval_result: tfma.EvalResult,
baseline_name: Text, metric_name: Text) -> float:
"""Looks through the evaluation result for the value of the baseline slice.
Args:
eval_result: Loaded eval result from running TensorFlow Model Analysis.
baseline_name: Name of the baseline slice, 'Overall' or a specified tuple.
metric_name: Name of the metric on which to perform comparisons.
Returns:
Percentage value of the baseline slice name requested.
Raises:
Value error if the baseline slice is not found in eval_results.
"""
for metrics_tuple in eval_result.slicing_metrics:
slice_tuple = metrics_tuple[0]
if baseline_name == 'Overall' and not slice_tuple:
return _get_metric_value(metrics_tuple[1], metric_name)
if baseline_name == slice_tuple:
return _get_metric_value(metrics_tuple[1], metric_name)
raise ValueError('Could not find baseline %s in eval_result: %s' %
(baseline_name, eval_result))