Read and deserialize the MetricForSlice records as Pandas dataframe.

One typical use of this dataframe table is to re-organize it in the form of slices vs. metrics table. E.g., for single model single output: result.pivot(index='slice', columns='name', values='display_value'). This only works when there is one unique value as the pivot values. Otherewise, a user needs to specify more columns or indices to make sure that the metric value is unique per column and per index. E.g., for single model and multiple outputs: result.pivot(index='slice', columns=['output_name', 'name'], values='display_value'). Args: output_path: the directory path of the metrics file. output_file_format: the file format of the metrics file, such as tfrecord. include_empty_columns: include a column if its value is not empty (None) in corresponding field in the MetricKey.

A dataframe with the following columns if the value is not None:

  • slice: the string representation of the slice, e.g., "age=10;sex=male".
  • recursively flattened items in metric_key: name, model_name, output_name, is_diff, example_weighted, flattened sub_key (class_id, k, top_k), flattened aggregation_type (micro_average, macro_average, weighted_macro_average).
  • metric_value: a tfma.metrics.MetricValue proto.
  • confidence_interval: a tfma.metrics.ConfidenceInterval proto.
  • display_value: a best effort string reprensentation of the underlying metric value and confidence interval if turned on.