Close
Sidebar
Search tutorials
Get Started
Documentation
XCurve.Metrics.PartialAUROC
Compute Partial AUROC value with $TPR\in[\alpha, 1]$ and $BPR\in[0,\beta]$. $$ \text{AUROC}_{\alpha,\beta} (f) = \frac{1}{n_+^\alpha n_-^\beta} \sum_{i=1}^{n_+^\alpha} \sum_{j=1}^{n_-^\beta} \mathbb{I} [f(x_{[i]}^+) > f(s_{[j]}^-)], $$ where $n_+^\alpha = \lfloor n_+ \cdot \alpha\rfloor$, $n_-^{\beta} = \lceil n_- \cdot\beta \rceil$, $x_{[i]}^+$ is $i$-th smallest score among all positive instances and $x_{[j]}^-$ is $j$-th largest score among all negative instances. Note that, PartialAUROC only supports binary cases. For more details, please refer to the literature:When All We Need is a Piece of the Pie: A Generic Framework for Optimizing Two-way Partial AUC. Zhiyong Yang, Qianqian Xu, Shilong Bao, Yuan He, Xiaochun Cao and Qingming Huang. ICML, 2021.
|
True labels or binary label indicators (numpy array with shape (n_samples,)). Prediction score (numpy array with shape (n_samples,) for binary case, (n_samples, n_classes) for multiclass case). $\alpha\in(0,1]$. If $\alpha=1$, it becomes OPAUC scheme. $\beta\in(0,1]$. |
---|---|
|
return corresponding AUROC score. |
Example:
from XCurve.Metrics import PartialAUROC
import numpy as np
# binary cases
y_true = np.asarray([1, 0] * 50)
y_pred = np.random.rand(100)
binary_auc=PartialAUROC(y_true=y_true, y_pred=y_pred, min_tpr=1, max_fpr=0.5)
print(binary_auc)