Close
Sidebar
Search tutorials
Get Started
Documentation
XCurve.Metrics.AUTKC
Compute AUTKC for each K in the specified K-list. For each K value, this metric can be denoted as: $$ \text{AUTKC}(f) = \frac{1}{nK}\sum_{i=1}^{n}\sum_{k=1}^{K} \mathbb{I} (f(x_i)_{y_i}>f(x_i)_{[k]}) $$ where $f(x_i)_{y_i}$ is the score of the ground-truth label, $f(x_i)_{[k]}$ is the $k$-largest value in $f(x)\in\mathbb{R}^C$, $C$ denotes the number of classes, and $\mathbb{I}(\cdot)$ is the indicator function. For more details, please refer to the literature:Optimizing Partial Area Under the Top-k Curve: Theory and Practice. Zitai Wang, Qianqian Xu, Zhiyong Yang, Yuan He, Xiaochun Cao and Qingming Huang. T-PAMI, 2023.
|
Prediction score (torch array with shape (n_samples, n_classes)). True labels (torch array with shape (n_samples,)). The specified k-list. |
---|---|
|
return the AUTKC value for each K in the specified K-list, where the values are multiplied by 100. |
Example:
from Metrics import AUTKC
import numpy as np
import torch
n_samples, C = 10, 5
k_list = (1, 3)
y_true = np.random.randint(low=0, high=C, size=(n_samples, ))
y_pred = np.random.rand(n_samples, C)
print(y_true, y_pred)
y_true = torch.LongTensor(y_true)
y_pred = torch.tensor(y_pred)
autkc=AUTKC(y_pred, y_true, k_list)
print(autkc)