SetSize#

class torch_uncertainty.metrics.classification.SetSize(reduction='mean', **kwargs)[source]#

Set size to compute the efficiency of conformal prediction methods.

Parameters:
  • reduction (str, optional) –

    Determines how to reduce over the \(B\)/batch dimension:

    • 'mean' [default]: Averages score across samples

    • 'sum': Sum score across samples

    • 'none' or None: Returns score per sample

  • kwargs – Additional keyword arguments, see Advanced metric settings.

compute()[source]#

Compute the mean set size.

Returns:

The coverage rate.

Return type:

Tensor

update(preds, targets=None)[source]#

Update the metric state with predictions and targets.

Parameters:
  • preds (torch.Tensor) – predicted sets tensor of shape (B, C), where B is the batch size and C is the number of classes.

  • targets (torch.Tensor) – For API consistency