Configuration

The metrics block scores model predictions. The _target_ field is the discriminator: it selects one of four adapters, each with its own set of valid keys.

  • BinaryClassificationMetrics — two-class problems (accuracy, precision, recall, F1).

  • MulticlassClassificationMetrics — single-label multiclass classification (one correct class per sample).

  • MultilabelClassificationMetrics — multilabel classification (multiple correct classes per sample, independent per-label decisions).

  • DetectionMetrics — object detection (mean average precision and related summaries via torchmetrics).

The previous unified ClassificationMetrics target with a task: binary | multiclass | multilabel field has been removed. Pick the task-specific adapter directly via _target_; each adapter only accepts the keys documented for its section below.

See Underlying libraries for the backend behaviour behind each adapter.

Binary classification

Configures BinaryClassificationMetrics for two-class problems.

Options

Name

Allowed

Default

Description

_target_

"BinaryClassificationMetrics"

"BinaryClassificationMetrics"

Selects the binary-classification adapter.

ignore_index

integer, null

null

Optional target value to ignore when computing metrics.

threshold

float

0.5

Decision threshold applied to predicted probabilities to obtain the positive class.

Examples

metrics:
  _target_: "BinaryClassificationMetrics"
from raitap.metrics import binary_classification

metrics = binary_classification()
uv run raitap +metrics=binary_classification +metrics.threshold=0.6
raitap +metrics=binary_classification +metrics.threshold=0.6

Multiclass classification

Configures MulticlassClassificationMetrics for single-label multiclass problems.

Options

Name

Allowed

Default

Description

_target_

"MulticlassClassificationMetrics"

"MulticlassClassificationMetrics"

Selects the multiclass-classification adapter.

num_classes

integer

required

Number of classes. Must be positive. Required.

average

"micro", "macro", "weighted", "none"

"macro"

Aggregation mode passed to the underlying TorchMetrics implementations. See Underlying libraries for semantics.

ignore_index

integer, null

null

Optional target value to ignore when computing metrics.

Examples

metrics:
  _target_: "MulticlassClassificationMetrics"
  num_classes: 7
from raitap.metrics import multiclass_classification

metrics = multiclass_classification(num_classes=7)
uv run raitap +metrics=multiclass_classification +metrics.num_classes=7
raitap +metrics=multiclass_classification +metrics.num_classes=7

Multilabel classification

Configures MultilabelClassificationMetrics for multilabel problems (independent per-label decisions).

Options

Name

Allowed

Default

Description

_target_

"MultilabelClassificationMetrics"

"MultilabelClassificationMetrics"

Selects the multilabel-classification adapter.

num_labels

integer

required

Number of labels. Must be positive. Required.

average

"micro", "macro", "weighted", "none"

"macro"

Aggregation mode passed to the underlying TorchMetrics implementations.

ignore_index

integer, null

null

Optional target value to ignore when computing metrics.

threshold

float

0.5

Per-label decision threshold applied to predicted probabilities.

Examples

metrics:
  _target_: "MultilabelClassificationMetrics"
  num_labels: 5
from raitap.metrics import multilabel_classification

metrics = multilabel_classification(num_labels=5)
uv run raitap +metrics=multilabel_classification +metrics.num_labels=5
raitap +metrics=multilabel_classification +metrics.num_labels=5

Object detection

Configures DetectionMetrics, which wraps torchmetrics MeanAveragePrecision. The IoU-related knobs are grouped under the nested iou: block.

Options

Name

Allowed

Default

Description

_target_

"DetectionMetrics"

"DetectionMetrics"

Selects the object-detection adapter.

box_format

"xyxy", "xywh"

"xyxy"

Bounding-box format of incoming predictions and targets. torchvision detectors output xyxy.

iou.type

"bbox", "segm", or a tuple of those values

"bbox"

IoU mode passed to mean average precision.

iou.thresholds

list[float], null

null

Optional custom IoU thresholds. null uses the torchmetrics default (COCO-style sweep).

iou.rec_thresholds

list[float], null

null

Optional custom recall thresholds. null uses the torchmetrics default.

iou.max_detection_thresholds

list[int], null

null

Optional maximum-detection cutoffs. null uses the torchmetrics default.

class_metrics

true, false

false

Whether to compute per-class metrics in addition to global summaries.

extended_summary

true, false

false

Whether to request the torchmetrics extended (non-scalar) summary outputs as artifacts.

average

"macro", "micro"

"macro"

Aggregation mode for detection summaries.

backend

"faster_coco_eval", "pycocotools"

"faster_coco_eval"

Backend used by mean average precision. pycocotools should be used only for backward compatibility.

Examples

metrics:
  _target_: "DetectionMetrics"
  iou:
    thresholds: [0.5, 0.75]
  class_metrics: true
from raitap.metrics import detection

metrics = detection(
    iou={"thresholds": [0.5, 0.75]},
    class_metrics=True,
)
uv run raitap +metrics=detection +metrics.class_metrics=true +metrics.extended_summary=true
raitap +metrics=detection +metrics.class_metrics=true +metrics.extended_summary=true