Realm

oa::ml::metric::precision_recall_f1

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.

FnRust public API

Function Documentation

pub fn precision_recall_f1( logits: &Matrix, labels: &Matrix, class_index: usize ) -> Result<ClassificationCounts>
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.