# tfma.writers.convert_slice_metrics_to_proto

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/model-analysis/blob/v0.46.0/tensorflow_model_analysis/writers/metrics_plots_and_validations_writer.py#L313-L413) |

Converts the given slice metrics into serialized proto MetricsForSlice.

    tfma.writers.convert_slice_metrics_to_proto(
        metrics: Tuple[slicer.SliceKeyOrCrossSliceKeyType, metric_types.MetricsDict],
        add_metrics_callbacks: Optional[List[types.AddMetricsCallbackType]]
    ) -> https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/MetricsForSlice

<br />

<br />

<br />

| ## Args ||
|---|---|
| `metrics` | The slice metrics. |
| `add_metrics_callbacks` | A list of metric callbacks. This should be the same list as the one passed to tfma.Evaluate(). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| The MetricsForSlice proto. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | If the type of the feature value in slice key cannot be recognized. |

<br />