oa::ml::metric
Module published by the oa::ml module.
MdRust public API
Public Types
Public Functions
Function Documentation
Compute last-axis categorical accuracy as a fraction in [0, 1]. Argmax and counting execute on the owning device. Only the resulting U32 scalar crosses the host boundary; this function then waits for that scalar. Equal maximum logits select the first class, matching the OA C++ contract. Errors Returns an error when matrix::categorical_accuracy_count rejects the logits or labels, or submission, completion, or scalar readback fails.
Corpus BLEU over token sequences with a brevity penalty, no smoothing. Counts clipped n-gram matches up to max_order across the corpus and combines them geometrically. A corpus with no matches at any order returns 0.0; hypotheses shorter than references receive the standard exp(1 - ref/hyp) penalty. Inputs are host token sequences — this is an evaluation-side metric, not a device op. Errors Returns an error when max_order is zero, the corpora differ in length, a hypothesis is empty, or any sequence is shorter than max_order.
Macro-averaged F1 over num_classes one-vs-rest counts. Errors Returns an error when num_classes is zero or any per-class count fails.
Per-class prediction/label counts behind one-vs-rest metrics. Logits and labels are read back and the last-axis argmax runs on the host — the same explicit host-observation boundary as scalar_loss, sized for evaluation batches rather than hot loops. A class absent from both predictions and labels reports 0.0 for all derived values rather than a NaN. Equal maximum logits select the first class, matching the OA device argmax contract. Errors Returns an error when logits is not rank-two F32 ["samples", C], labels does not carry one U32/I32 label per row, class_index is out of range for the class axis, or readback fails.
Binary ROC AUC from positive-class scores against binary labels. Scores and labels are read back and ranked on the host with the Mann-Whitney formulation (tied scores share average rank), so the value is exactly the probability that a random positive outranks a random negative. This is an evaluation-side host metric, not a capture-safe device op. Errors Returns an error when scores is not F32, shapes disagree, labels are not 0/1, or one class is absent.
Read one scalar FP32 loss value. This is an explicit host-observation boundary: pending work is submitted and the producing event is awaited before the value is returned. Errors Returns an error unless loss contains exactly one F32 value, or submission, completion, or readback fails.