Top-K Accuracy

Metric computing the per-head top-k accuracy for classification: the fraction of samples whose true class falls within the k highest-scoring predictions. With k = 1 this is ordinary top-1 accuracy.

Configuration

Selected as name: top-k-acc.

Option

Description

Type

Default

k

Number of top-scoring classes considered a correct prediction.

int

1

services:
  metrics:
    select:
      - name: top-k-acc
        kwargs: { k: 3 }