top_k_accuracy

Function top_k_accuracy 

Source
pub fn top_k_accuracy(
    scores: &[f64],
    targets: &[usize],
    n_classes: usize,
    k: usize,
) -> f64
Expand description

Top-K accuracy: fraction of samples where the true class is in the top-K predictions.

scores is a flat array of shape [n_samples, n_classes] with raw logits/probs.