Skip to content
EvalSuite
Documentation menu

Classification

Top-k accuracy

Implementedclassification.top_k_accuracy

Definition

Proportion of observations whose true class is among the k classes with the highest probability.

Formula

(1/n) Σᵢ 1[yᵢ ∈ top-k(p̂ᵢ)]

Range: [0, 1]

Inputs and outputs

  • y_true: class labels
  • y_prob: (n, k) class probabilities

Returns: MetricResult

Assumptions

No assumptions beyond valid, aligned inputs of the documented types.

Limitations

No metric-specific limitations are documented yet. Interpret the value alongside the task, data, and other metrics.

Python API

PythonSince v0.1.0
import evalsuite as es

es.top_k_accuracy(y_true_k, y_prob_k, k=2)

References

  1. Russakovsky O, et al. ImageNet Large Scale Visual Recognition Challenge. IJCV. 2015;115:211-252.

Implementation status