incerto.ood.compute_threshold_at_tpr

incerto.ood.compute_threshold_at_tpr#

incerto.ood.compute_threshold_at_tpr(id_scores, target_tpr=0.95)[source]#

Compute OOD score threshold that accepts target_tpr fraction of ID samples.

The threshold is set at the target_tpr-th percentile of the ID score distribution, so that target_tpr of in-distribution samples fall below it (i.e. are correctly classified as ID).

Parameters:
  • id_scores (Tensor | ndarray) – Scores from in-distribution data (lower = more ID-like).

  • target_tpr (float) – Fraction of ID samples to accept (default: 0.95).

Return type:

float

Returns:

Threshold value.