probly.visualization.efficiency.coverage_efficiency_ood¶
Coverage-Efficiency visualization for ID vs. OOD data.
Functions
Bridge function: plot Coverage-Efficiency using OOD-style label convention. |
|
|
Plot Coverage-Efficiency for ID and OOD data side by side. |
- probly.visualization.efficiency.coverage_efficiency_ood.plot_coverage_efficiency_from_ood_labels(probs, targets, ood_labels, *, id_label=0, ood_label=1, title_id='Coverage vs. Efficiency (ID)', title_ood='Coverage vs. Efficiency (OOD)', figsize=(14.0, 5.0))[source]¶
Bridge function: plot Coverage-Efficiency using OOD-style label convention.
This is the main connection point between the OOD evaluation pipeline and the coverage-efficiency visualization.
- The OOD API constructs labels like:
labels = [0 … 0, 1 … 1]
- where:
0 = ID, 1 = OOD
This function accepts such ood_labels and splits probs/targets accordingly.
- Parameters:
probs (np.ndarray | list[list[float]]) – (N, C) class probabilities for all samples.
targets (np.ndarray | list[int]) – (N,) integer class labels for all samples.
ood_labels (np.ndarray | list[int] | list[float]) – (N,) markers indicating ID vs OOD membership.
id_label (int) – Value in ood_labels that marks in-distribution samples (default: 0).
ood_label (int) – Value in ood_labels that marks out-of-distribution samples (default: 1).
title_id (str) – Title for the ID subplot.
title_ood (str) – Title for the OOD subplot.
- Returns:
Matplotlib Figure and the two Axes objects.
- Return type:
(fig, (ax_id, ax_ood))
- Raises:
ValueError – If shapes do not match, or if no samples are found for ID/OOD.
- probly.visualization.efficiency.coverage_efficiency_ood.plot_coverage_efficiency_id_ood(probs_id, targets_id, probs_ood, targets_ood, *, title_id='Coverage vs. Efficiency (ID)', title_ood='Coverage vs. Efficiency (OOD)', figsize=(14.0, 5.0))[source]¶
Plot Coverage-Efficiency for ID and OOD data side by side.
This function does not compute ID/OOD splits. It assumes inputs are already split.
- Parameters:
probs_id (np.ndarray) – (N_id, C) class probabilities for in-distribution samples.
targets_id (np.ndarray) – (N_id,) integer class labels for in-distribution samples.
probs_ood (np.ndarray) – (N_ood, C) class probabilities for out-of-distribution samples.
targets_ood (np.ndarray) – (N_ood,) integer class labels for out-of-distribution samples. Note: For some OOD datasets “true” targets may be undefined. In that case, consider passing proxy labels (e.g. argmax) and interpreting OOD coverage carefully.
title_id (str) – Title for the ID subplot.
title_ood (str) – Title for the OOD subplot.
- Returns:
Matplotlib Figure and the two Axes objects.
- Return type:
(fig, (ax_id, ax_ood))