{
  "$schema": "https://ambiqai.github.io/helia-ui/schema/reference-model-1.json",
  "generatedFrom": {
    "sourceCommit": "f341fb11f7f5d77a4974ba8273c4cd55d67c21f0",
    "tool": "pyref",
    "version": "1.7.3"
  },
  "language": "python",
  "modules": [
    {
      "description": "# Metrics Utils API\n\nThis module provides utility functions to compute metrics for classification tasks.\n\n**Functions**\n\n| Name | Description |\n| --- | --- |\n| `compute_metrics` | Compute set of metrics for y_true and y_pred |\n| `confusion_matrix` | Compute confusion matrix using keras w/ addition to normalize |",
      "name": "metric_utils",
      "path": "helia_edge.metrics.metric_utils",
      "submodules": [],
      "summary": "Metrics Utils API",
      "symbols": [
        {
          "description": "",
          "examples": [],
          "id": "helia_edge.metrics.metric_utils.logger",
          "kind": "attribute",
          "language": "python",
          "members": [],
          "name": "logger",
          "params": [],
          "raises": [],
          "returns": [],
          "signature": "logger = logging.getLogger(__name__)",
          "source": {
            "line": 18,
            "path": "helia_edge/metrics/metric_utils.py",
            "url": "https://github.com/AmbiqAI/helia-edge/blob/f341fb11f7f5d77a4974ba8273c4cd55d67c21f0/helia_edge/metrics/metric_utils.py#L18"
          },
          "summary": ""
        },
        {
          "description": "Compute set of metrics for y_true and y_pred.\n\nExample:\n\n```python\nimport helia_edge as helia\n\nmetrics = [keras.metrics.Accuracy('acc'), keras.metrics.Precision(0.5, name='precision')]\ny_true = np.array([0, 1, 1, 0])\ny_pred = np.array([0, 1, 0, 1])\nresults = helia.metrics.compute_metrics(metrics, y_true, y_pred)\nprint(results)\n```",
          "examples": [],
          "id": "helia_edge.metrics.metric_utils.compute_metrics",
          "kind": "function",
          "language": "python",
          "members": [],
          "name": "compute_metrics",
          "params": [
            {
              "description": "List of metrics",
              "name": "metrics",
              "type": "list[keras.Metric]"
            },
            {
              "description": "True labels",
              "name": "y_true",
              "type": "keras.KerasTensor"
            },
            {
              "description": "Predicted labels",
              "name": "y_pred",
              "type": "keras.KerasTensor"
            }
          ],
          "raises": [],
          "returns": [
            {
              "description": "Dictionary of metric names and values",
              "name": "dict",
              "type": "dict[str, float]"
            }
          ],
          "signature": "compute_metrics(metrics: list[keras.Metric], y_true: keras.KerasTensor, y_pred: keras.KerasTensor) -> dict[str, float]",
          "source": {
            "line": 21,
            "path": "helia_edge/metrics/metric_utils.py",
            "url": "https://github.com/AmbiqAI/helia-edge/blob/f341fb11f7f5d77a4974ba8273c4cd55d67c21f0/helia_edge/metrics/metric_utils.py#L21"
          },
          "summary": "Compute set of metrics for ytrue and ypred."
        },
        {
          "description": "Compute confusion matrix using keras w/ addition to normalize.\n\n:::note[Normalization modes]\n- \"true\": Normalize by true labels\n- \"pred\": Normalize by predicted labels\n- \"all\": Normalize by all labels\n\n:::\n\nExample:\n\n```python\nimport helia_edge as helia\n\nlabels = np.array([0, 1, 1, 0])\npredictions = np.array([0, 1, 0, 1])\nnum_classes = 2\ncm = helia.metrics.confusion_matrix(labels, predictions, num_classes, normalize='true')\nprint(cm)\n```",
          "examples": [],
          "id": "helia_edge.metrics.metric_utils.confusion_matrix",
          "kind": "function",
          "language": "python",
          "members": [],
          "name": "confusion_matrix",
          "params": [
            {
              "description": "True labels",
              "name": "labels",
              "type": "keras.KerasTensor"
            },
            {
              "description": "Predicted labels",
              "name": "predictions",
              "type": "keras.KerasTensor"
            },
            {
              "description": "Number of classes",
              "name": "num_classes",
              "type": "int"
            },
            {
              "default": "None",
              "description": "Weights. Defaults to None.",
              "name": "weights",
              "type": "keras.KerasTensor"
            },
            {
              "default": "'int32'",
              "description": "Data type. Defaults to \"int32\".",
              "name": "dtype",
              "type": "str"
            },
            {
              "default": "None",
              "description": "Normalization mode. Defaults to None.",
              "name": "normalize",
              "type": "Literal['true', 'pred', 'all']"
            }
          ],
          "raises": [],
          "returns": [
            {
              "description": "keras.KerasTensor: Confusion matrix",
              "type": "keras.KerasTensor"
            }
          ],
          "signature": "confusion_matrix(\n    labels: keras.KerasTensor,\n    predictions: keras.KerasTensor,\n    num_classes: int,\n    weights: keras.KerasTensor | None = None,\n    dtype: str = 'int32',\n    normalize: Literal['true', 'pred', 'all'] | None = None,\n) -> keras.KerasTensor",
          "source": {
            "line": 55,
            "path": "helia_edge/metrics/metric_utils.py",
            "url": "https://github.com/AmbiqAI/helia-edge/blob/f341fb11f7f5d77a4974ba8273c4cd55d67c21f0/helia_edge/metrics/metric_utils.py#L55"
          },
          "summary": "Compute confusion matrix using keras w/ addition to normalize."
        }
      ]
    }
  ],
  "name": "helia_edge"
}
