SetSize#
- class torch_uncertainty.metrics.classification.SetSize(reduction='mean', **kwargs)[source]#
Average prediction-set size — the standard efficiency metric for conformal prediction methods.
For a set-valued predictor \(\mathcal{C}(X) \subseteq \{1, \dots, C\}\),
\[\text{SetSize} = \frac{1}{N} \sum_{i=1}^{N} |\mathcal{C}(x_i)|.\]Smaller sets are more informative, hence
higher_is_better = False. Set size is typically reported jointly with the empiricalCoverageRate: a useful conformal predictor achieves the target coverage with as small a set as possible.- Parameters:
reduction (
Optional[Literal['mean','sum','none']]) –Determines how to reduce over the \(B\)/batch dimension:
'mean'[default]: Averages score across samples'sum': Sum score across samples'none'orNone: Returns score per sample
kwargs – Additional keyword arguments, see Advanced metric settings.
- compute()[source]#
Compute the set size.
- Returns:
The set size according to the selected reduction.
- Return type:
Tensor
- update(preds, targets=None)[source]#
Update the metric state with predictions and targets.
- Parameters:
preds (
Tensor) – Predicted sets tensor of shape(B, C), whereBis the batch size andCis the number of classes.targets (
Tensor|None) – Unused. Kept for API consistency. Defaults toNone.
- Return type:
None