SCODRiskAtxCov#
- class torch_uncertainty.metrics.classification.SCODRiskAtxCov(cov_threshold, ood_cost=0.5, **kwargs)[source]#
Calculate the SCOD risk at a specified coverage.
This metric applies
RiskAtxCovto the joint SCOD loss defined bySCODAURC.For a target coverage \(\gamma\in[0,1]\), let
\[k_\gamma = \left\lceil \gamma N \right\rceil.\]Samples are ordered from lowest to highest OOD score, and the reported SCOD risk is
\[\operatorname{SCOD\text{-}Risk@Cov}(\gamma) = r\left(\frac{k_\gamma}{N}\right) = \frac{1}{k_\gamma} \sum_{j=1}^{k_\gamma}\ell_{\sigma(j)}.\]As input to
forwardandupdate, the metric accepts:ood_scores (
Tensor): Float tensor containing OOD scores, where larger values indicate more OOD-like samples.classification_errors (
Tensor): Boolean or binary tensor indicating misclassified ID samples.is_ood (
Tensor): Boolean or binary tensor indicating OOD samples.
As output to
forwardandcompute, the metric returns:scod_risk (
Tensor): Scalar tensor containing the SCOD risk at the requested coverage. Lower values are better.
- Parameters:
cov_threshold (
float) – Target coverage \(\gamma\).ood_cost (
float) – Relative cost \(c_{\mathrm{OOD}}\) of accepting an OOD sample. The cost of accepting a misclassified ID sample is1 - ood_cost. Defaults to0.5.kwargs – Additional keyword arguments passed to
torchmetrics.Metric.
References
[2] Narasimhan et al. Plugin Estimators for Selective Classification with Out-of-Distribution Detection..
See also
SCODAURC:Definition of the SCOD loss and selective risk.
RiskAtxCov:Corresponding selective-classification metric.