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 |
|---|---|---|---|
|
|
|
Selects the binary-classification adapter. |
|
|
|
Optional target value to ignore when computing metrics. |
|
|
|
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 |
|---|---|---|---|
|
|
|
Selects the multiclass-classification adapter. |
|
|
|
Number of classes. Must be positive. Required. |
|
|
|
Aggregation mode passed to the underlying TorchMetrics implementations. See Underlying libraries for semantics. |
|
|
|
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 |
|---|---|---|---|
|
|
|
Selects the multilabel-classification adapter. |
|
|
|
Number of labels. Must be positive. Required. |
|
|
|
Aggregation mode passed to the underlying TorchMetrics implementations. |
|
|
|
Optional target value to ignore when computing metrics. |
|
|
|
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 |
|---|---|---|---|
|
|
|
Selects the object-detection adapter. |
|
|
|
Bounding-box format of incoming predictions and targets. torchvision detectors output |
|
|
|
IoU mode passed to mean average precision. |
|
|
|
Optional custom IoU thresholds. |
|
|
|
Optional custom recall thresholds. |
|
|
|
Optional maximum-detection cutoffs. |
|
|
|
Whether to compute per-class metrics in addition to global summaries. |
|
|
|
Whether to request the torchmetrics extended (non-scalar) summary outputs as artifacts. |
|
|
|
Aggregation mode for detection summaries. |
|
|
|
Backend used by mean average precision. |
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