Operational Decision Framework
Zone Classification
Classify samples into operational zones based on outcomes:
- Safe Zone: SC predictions (automate with confidence)
- Uncertain Zone: TS predictions (need manual review)
- Problematic Zone: SI predictions (model failures)
from conformalpy.framework import classify_zones, zone_summary
zones = classify_zones(prediction_sets, y_test)
summary = zone_summary(prediction_sets, y_test)Cost-Benefit Analysis
Quantify the value of using conformal prediction:
from conformalpy.framework import CostMatrix, compute_cp_value_analysis
costs = CostMatrix(
true_negative_cost=0, # Correctly approved good loan
true_positive_cost=0, # Correctly rejected default
false_negative_cost=1000, # Approved a defaulter (BAD)
false_positive_cost=100, # Rejected a good borrower
manual_review_cost=50, # Cost to manually review
)
analysis = compute_cp_value_analysis(
prediction_sets, y_test, y_pred, costs,
human_accuracy=0.85
)
print(f"Cost savings: ${analysis['delta_cost']:,.0f}")
print(f"Breakeven accuracy: {analysis['breakeven_accuracy']:.1%}")The analysis compares:
- Baseline: Full automation using point predictions
- CP + Perfect Review: CP with human reviewers who are 100% accurate
- CP + Realistic Review: CP with realistic human accuracy
See the CP value analysis example for a complete cost-benefit analysis workflow.
Accuracy-Coverage Curve
Visualize the trade-off between automation and accuracy:
from conformalpy.evaluation import (
compute_accuracy_coverage_curve,
plot_accuracy_coverage_curve,
)
curve = compute_accuracy_coverage_curve(
conf_clf, X_cal, y_cal, X_test, y_test,
alpha_range=(0.01, 0.30),
)
fig, ax = plot_accuracy_coverage_curve(curve)- Coverage: Proportion of singleton predictions (automation rate)
- Accuracy: Correctness among singletons only
Feature-Conditioned Outcome Distributions
Outcome FCODs show how outcome proportions vary with features:
from conformalpy.fcod import (
compute_fcod_smoothed,
plot_stacked_fcod,
)
fcod = compute_fcod_smoothed(
feature_values,
prediction_sets,
y_test,
n_grid=50,
percentile_range=(5, 95), # Trim sparse extremes
)
fig, ax = plt.subplots()
plot_stacked_fcod(fcod, ax=ax)Key insight: FCODs reveal feature ranges where:
- Model is consistently confident (high SC)
- Model is uncertain (high TS)
- Model is dangerously overconfident (high SI)
Grid Trimming
Use percentile_range to focus on data-rich regions:
# Full range (may be noisy at extremes)
fcod_full = compute_fcod_smoothed(feature, pred_sets, y_test)
# Trimmed to 5th-95th percentile (more stable)
fcod_trimmed = compute_fcod_smoothed(
feature, pred_sets, y_test,
percentile_range=(5, 95)
)See the FCOD visualization example for FCOD visualizations and the FCOD model comparison example for comparing models.