# tfma.metrics.SubKey

<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/metrics/metric_types.py#L36-L133) |

A SubKey identifies a sub-types of metrics and plots.

    tfma.metrics.SubKey(
        class_id: Optional[int] = None,
        k: Optional[int] = None,
        top_k: Optional[int] = None
    )

Only one of class_id, k, or top_k can be set at a time.

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `class_id` | Used with multi-class metrics to identify a specific class ID. |
| `k` | Used with multi-class metrics to identify the kth predicted value. |
| `top_k` | Used with multi-class and ranking metrics to identify top-k predicted values. |

<br />

## Methods

### `from_proto`

[View source](https://github.com/tensorflow/model-analysis/blob/v0.46.0/tensorflow_model_analysis/metrics/metric_types.py#L118-L133)

    @staticmethod
    from_proto(
        pb: metrics_for_slice_pb2.SubKey
    ) -> Optional['SubKey']

Creates class from proto.

### `to_proto`

[View source](https://github.com/tensorflow/model-analysis/blob/v0.46.0/tensorflow_model_analysis/metrics/metric_types.py#L107-L116)

    to_proto() -> metrics_for_slice_pb2.SubKey

Converts key to proto.