outcomes

outcomes

Outcome categorization for conformal prediction.

This module provides functions to categorize conformal prediction sets into interpretable outcomes for both binary and multiclass classification.

Categorization Functions: - categorize_outcomes: Assign each sample to an outcome category - categorize_outcomes_vectorized: Fast vectorized version

Counting & Proportions: - outcome_counts: Count samples per outcome - outcome_proportions: Proportion of samples per outcome - outcome_summary: Comprehensive statistics

SI Error Analysis: - si_error_analysis: Breakdown of SI errors by predicted class - si_error_report: Formatted text report of SI errors

Singleton Confusion Matrix: - singleton_confusion_matrix: Confusion matrix for singleton predictions - singleton_confusion_report: Formatted text report of singleton analysis

Utility Functions: - outcome_indicators: Boolean arrays for each outcome - get_outcome_mask: Filter samples by outcome(s) - get_outcome_keys: Get canonical outcome key list for a given n_classes

Outcome Definitions (Binary Classification, K=2):

Outcome Meaning
SC Single Correct: Confident and correct
SI Single Incorrect: Confident but wrong (failure mode)
TS0 Two-Set true=0: Uncertain, actual outcome was negative
TS1 Two-Set true=1: Uncertain, actual outcome was positive
Empty Empty set: No class meets threshold

Outcome Definitions (Multiclass Classification, K>2):

Outcome Meaning
SC Single Correct: Confident and correct
SI Single Incorrect: Confident but wrong (failure mode)
MC Multi-set Covered: Uncertain, true label IS in the set
MU Multi-set Uncovered: Uncertain, true label NOT in the set
Empty Empty set: No class meets threshold

Example

from conformalpy.outcomes import categorize_outcomes, outcome_summary prediction_sets = [{0}, {1}, {0, 1}, {0, 1}, {0}] y_true = [0, 0, 0, 1, 0] categorize_outcomes(prediction_sets, y_true) array([‘SC’, ‘SI’, ‘TS0’, ‘TS1’, ‘SC’], dtype=‘<U5’) summary = outcome_summary(prediction_sets, y_true) print(f”Confidence rate: {summary[‘confidence_rate’]:.0%}“) Confidence rate: 60%