Module metrics

Module metrics 

Source

Structs§

ClassMetrics
Per-class metric report entry.
ConfusionMatrix
NxN confusion matrix. Entry [i][j] = count of samples with true class i predicted as class j.

Enums§

Average
How to average per-class metrics for multi-class problems.

Functions§

accuracy
Classification accuracy: fraction of correct predictions.
argmax_classes
Compute argmax along the last axis, returning class indices.
classification_report
Per-class precision, recall, F1, and support — like sklearn’s classification_report.
f1_score
F1 Score — harmonic mean of precision and recall.
mae
Mean Absolute Error: mean(|y_true - y_pred|).
mape
Mean Absolute Percentage Error: mean(|y_true - y_pred| / |y_true|) * 100.
perplexity
Perplexity from cross-entropy loss: exp(loss).
perplexity_from_log_probs
Perplexity from a flat array of per-token log-probabilities.
precision
Precision for multi-class classification.
r2_score
R² (coefficient of determination).
recall
Recall for multi-class classification.
rmse
Root Mean Squared Error: sqrt(mean((y_true - y_pred)²)).
tensor_accuracy
Compute accuracy directly from logit tensors and one-hot/class-index targets.
top_k_accuracy
Top-K accuracy: fraction of samples where the true class is in the top-K predictions.