Metric

Note

This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.

class Metric(*args, **kwargs)[source]

Bases: Protocol

Evaluation metric with explicit input requirements.

The needs_proba flag declares whether the metric consumes class probabilities/scores (AUC, calibration tests) or hard labels (accuracy, sensitivity); evaluation drivers use it instead of guessing from the metric name.

property spec: Spec

Return the metric specification.

__call__(y_true: ndarray, y_pred: ndarray, y_score: ndarray | None = None) → float[source]

Compute the metric value.

Parameters:
  • y_true – True class labels.

  • y_pred – Predicted class labels.

  • y_score – Probability/score of the positive class; required when needs_proba is true.

Returns:

The metric value (NaN where the metric is undefined for the given inputs, e.g. calibration tests on multi-class problems).

__init__(*args, **kwargs)