Classification
Top-k accuracy
Implemented
classification.top_k_accuracyDefinition
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
import evalsuite as es
es.top_k_accuracy(y_true_k, y_prob_k, k=2)References
- Russakovsky O, et al. ImageNet Large Scale Visual Recognition Challenge. IJCV. 2015;115:211-252.