Unit 7 of 11 · about 5 hours · implement

Calibration, decision thresholds and selective risk-coverage

This unit selects a complete prediction-and-action policy, then evaluates the frozen policy. The Classical ML units on recalibration and cost-sensitive thresholds supply the methods; the research question is whether better probabilities change the decision at acceptable coverage.

You'll be able to

  • Select calibration, decision and abstention rules without using their evaluation labels for tuning.
  • Report ranking, reliability, proper probability scores, decision loss and risk-coverage as different quantities.
  • Derive the reject rule from costs and test its tie and zero-coverage behavior.

Covers

Calibration, recalibration and decision thresholdsAbstention and selective risk-coverage behavior
1

Read

In this order, only the parts listed

0 of 3 done

  1. scikit-learn 1.9: audit the probability claimscikit-learn 1.9 - Probability Calibration

    Opening proper-scoring-rule note, Sections 1.16.1 to 1.16.3, and the isotonic ranking note and temperature-scaling subsection

    Skim familiar sigmoid and isotonic mechanics. Focus on independent calibration data, ties, multiclass argmax and the distinction between reliability and proper scores.

  2. scikit-learn 1.9: selecting the action thresholdscikit-learn 1.9 - Model Selection and Evaluation

    Sections 3.3.1.1 and 3.3.1.2, scoring choices and independent threshold-tuning data

  3. Murphy: the reject action has a costProbabilistic Machine Learning: An Introduction - Reject Option

    April 18, 2025 online draft: Chapter 5, Section 5.1.2, pp. 169 to 171, especially 5.1.2.3, Eqs. 5.11 to 5.15

2

Focus on

  • A ranking metric, a reliability curve, NLL or Brier loss, realized action cost and selective risk answer different questions. A constant prevalence predictor can be calibrated and unhelpful; a lower Brier score need not mean improved calibration.
  • Separate base fitting, calibrator fitting, threshold selection and evaluation, or nest the corresponding operations. With scikit-learn 1.9.1, use FrozenEstimator for an already-fitted base; prefit threshold tuning needs cv='prefit' and refit=False on separate tuning data. Supply a scorer matching the stated decision loss.
  • Under equal misclassification cost , zero correct-classification cost and rejection cost , classification has conditional loss . Reject when ; declare either action at equality. This optimum assumes the probabilities and loss model are correct.
  • Coverage is the accepted fraction; selective risk is mean loss among accepted cases. Report counts and sparse-slice reliability. At zero accepted cases, selective risk is undefined, not zero.
Common mistakes · 3
  • Choosing a cutoff from the evaluation risk-coverage curve, then reporting that same curve as independent confirmation.
  • Assuming abstention must monotonically improve realized risk. Finite samples and confidence misranking can reverse it.
  • Treating unchanged multiclass argmax under positive temperature scaling as unchanged decisions at every probability threshold.
3

Try it yourself

Closed-book, before checking anything

Derive Chow's rule by comparing conditional classification loss with rejection cost. With error cost 10, rejection cost 2 and top probabilities 0.6, 0.8 and 0.9, classification losses are 4, 2 and 1; reject the first, declare a tie policy for the second, and accept the third. Implement a threshold policy from a blank file. On the fixed evaluation table with these three confidences and correctness indicators [True, False, True], accepting at confidence at least 0.8 gives coverage and 0-1 selective risk , compared with full-coverage risk . These are constructed evaluation outcomes, not a calibration fit or a population guarantee. Test all-accepted, none-accepted and tied-confidence cases independently.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.Can recalibration improve NLL without improving accuracy?Answer

    Yes. Positive temperature scaling preserves the multiclass argmax while changing probabilities. NLL and cost-sensitive actions can change even when top-class accuracy does not.

  2. 2.Why can isotonic recalibration change ROC AUC?Answer

    Its non-decreasing step function can introduce ties. Ranking-based metrics may therefore change even without strict order reversals.

  3. 3.Does Chow's rule guarantee the accepted error rate stays below the rejection cost ratio on your test sample?Answer

    No. With true conditional probabilities it minimizes expected loss under the stated costs; a finite realized sample can differ. Estimated or shifted probabilities can also invalidate the assumed conditional losses.

5

Practice

  • Murphy Exercise 5.1: Reject option in classifiers

    April 18, 2025 online draft: Section 5.6, p. 204, Exercise 5.1, parts a and b

    Derive the optimum before consulting 5.1.2.3. Check your implementation by enumerating the conditional loss of every class action and rejection, with a tolerance for floating-point ties. The section mini-project covers the separate calibration, policy-selection and evaluation split audit.

  • scikit-learn: Probability Calibration curves - Gaussian Naive Bayes

    Dataset and Calibration curves / Gaussian Naive Bayes, through the first score table; stop before Linear support vector classifier

    Run with scikit-learn 1.9.1. Add bin counts and fixed cost-based actions to the reliability, NLL, Brier and AUC audit; do not select a calibrator from these evaluation scores and call its score independent. Correct the prose claim that no rank metrics are affected: isotonic ties and averaging separately fitted calibrated classifiers can change ranking.

You're done when

You solve Exercise 5.1, pass the policy edge-case checks, and use the example's separate metrics to explain why a calibration gain alone cannot establish lower decision loss.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 11 more in the section
  • Probabilistic Machine Learning: An Introduction - Reject OptionKevin Murphy · required

    In the April 18, 2025 online draft read 5.1.2 (cost-sensitive decisions, pp. 169 to 171) and 5.1.2.3, the reject option: with rejection cost and error cost , reject when the top class probability is below (Chow's rule, Eqs. 5.11 to 5.15), then derive it in Exercise 5.1. Section 12.5 adds that a constant predictor can be well calibrated and useless. Calibration and Bayesian model checking are deferred to the sequel; this is the selective-prediction source, not a calibration course.

  • scikit-learn 1.9 - Model Selection and Evaluationscikit-learn · support

    Run the nested versus non-nested iris example (its optimism is about 0.0076 accuracy over 30 splits; the split-to-split spread is descriptive, not a confidence interval), then use the grouped iterators (GroupKFold, StratifiedGroupKFold) in both inner and outer loops, the curve guides, and TunedThresholdClassifierCV: a decision threshold is a selected parameter, and tuning it on the fitting data overfits. Add tests that fail if preprocessing, selection or threshold tuning sees the final test fold.

  • scikit-learn 1.9 - Probability Calibrationscikit-learn · support

    Read the calibration guide (curves, sigmoid, isotonic and the newer temperature method; FrozenEstimator for an already-fitted model with separate calibration data), then run the calibration-curve example. A lower Brier score does not mean better calibration. Isotonic creates ties that can change ranking metrics; temperature keeps the multiclass argmax. Measure whether recalibration changes the cost-based decision and sparse-slice reliability, not only the reliability plot.

Also in this section

  • Model Evaluation, Model Selection, and Algorithm Selection in Machine LearningSebastian Raschka · primary

    Read v3 Section 1.1 (estimating a fitted model's performance, selecting a model and comparing algorithms "require different approaches"), 3.9 and Sections 4.8 to 4.15, with Figure 22 for nested cross-validation (Figure 16 is ordinary k-fold model selection). Decide which of the three claims your comparison makes before choosing a protocol. It assumes independent examples and mostly 0-1 loss, so its 5x2cv advice does not license treating clusters or folds as independent replicates.

  • On Over-fitting in Model Selection and Subsequent Selection Bias in Performance EvaluationCawley and Talbot, JMLR 2010 · required

    Read Section 4 (4.1, the bias and variance of the selection criterion, Figures 2 and 3) and Section 5 (internal evaluation and the median-hyperparameter protocol, Table 5). On heart, the biased protocol reports 16.730% error against 15.720% internal, a 1.010 point bias (standard error 0.186). Treat training and selection as one fitting procedure. The same protocol for every model is not automatically fair: selection bias depends on the algorithm, and these magnitudes do not transfer to neural searches.

  • Cross-validation: what does it estimate and how well does it do it?Bates, Hastie and Tibshirani · required

    Read v4 Sections 2, 3.1 and 4.1 to 4.3 with Figure 1; proofs are optional. Cross-validation targets average error over training sets more than the error of your fitted model, and naive fold intervals undercover: nominal 10% miscoverage became 31% in their simulation. Their nested estimator of the estimator's error is not GridSearchCV inside cross_val_score, and Theorem 1 assumes homoskedastic Gaussian linear regression with least squares.

  • The Elements of Statistical Learning - Chapter 7Hastie, Tibshirani and Friedman · required

    Second edition, corrected 12th printing: read 7.10.2 The Wrong and Right Way to Do Cross-validation (pp. 245 to 247) and 7.12 Conditional or Expected Test Error? (pp. 254 to 257); the rest of the chapter is reference. In the 7.10.2 example (50 samples, 5,000 noise predictors, screening before cross-validation) the average CV error was 3% against a true 50%: selection leakage, not a failure of cross-validation. Use the official download page.

  • A Unified Theory of Diversity in Ensemble LearningWood, Mu, Webb, Reeve, Luján and Brown, JMLR 2023 · required

    Read Section 2 (what ensemble diversity is), Section 4.1 (Theorem 5, the bias-variance-diversity decomposition of ensemble loss), 4.3 (estimating diversity from data) and 6.2 to 6.3 (good and bad diversity in majority voting). Diversity is a term to trade off against the members' bias and variance, not something to maximize. Compare a matched-budget ensemble with its best single member and report the decomposition, not only the aggregate accuracy.

  • Deep Learning Tuning Playbook - Scientific TuningGoogle Research · required

    At the pinned commit read A scientific approach to improving model performance, Exploration vs exploitation, Identifying scientific, nuisance, and fixed hyperparameters, Creating a set of studies, Striking a balance between informative and affordable experiments and Detecting whether a change is useful with isolation plots. A factor's role depends on the question: comparing depths requires retuning the learning rate. Declare whether budgets are equal trials, epochs, steps or wall time, include search overhead, and keep every valid run. Isolation plots are exploratory evidence.

  • STATS202 - Data Mining and AnalysisStanford University · support

    Use only the Kfold-CV and Shrinkage notes and Assignment 3 Q3 and Q4 (subset selection and lasso against known synthetic mechanisms; least squares, ridge, lasso and PCR). Repair the protocol before use: Assignment 2 Q6(j) and Assignment 4 Problem 3(d) choose settings on the "held out" data, which makes it a validation set, so add an untouched outer test; Assignment 3 Q5 prints y_i - g(x_i)^2 where the squared residual is meant. The labs are in R; recordings and grading need a Stanford account.

  • An Introduction to Statistical Learning with PythonSpringer and the authors · support

    Use the Python labs only where needed: Ch05-resample-lab.ipynb (Cross-Validation, The Bootstrap) and Ch06-varselect-lab.ipynb (selection by validation and cross-validation, ridge and lasso) at https://github.com/intro-stat-learning/ISLP_labs/tree/v2.2.1. Chapter 5 warns that the spread of split scores is not a valid estimate of the mean score's sampling variability; Chapter 6 lets only training observations choose each fold's subset. The Chapter 6 lab fits ridge with ElasticNet(l1_ratio=0) and silences warnings; prefer Ridge or RidgeCV with scaling inside the folds.

  • CS229 Public Materials - Learning Theory and Model SelectionStanford Engineering Everywhere · support

    Read ML-advice.pdf slides 6 to 24: capacity, optimization and objective diagnostics, and error analysis (current versus perfect performance) as distinct from ablation (baseline versus current). The slides warn that some advice does not suit novel research. notes4 (learning theory, pp. 1 to 11) is depth and notes5 (cross-validation, feature selection, Bayesian regularization) is reference; notes4 uses "bias" loosely for infinite-data error.

  • scikit-learn 1.9 - Computational Performancescikit-learn · support

    Sections 10.2.1.1 and 10.2.1.3 to 10.2.1.6: batch size, features, representation, model complexity and feature extraction in a model-family decision. Measure the whole pipeline on the intended request shape; the source's timings and rough scaling claims are not portable targets.

  • Shortcut Learning in Deep Neural NetworksGeirhos et al. · required

    arXiv:2004.07780v5: Section 3 and Figures 2 and 3, then Sections 6.1 and 6.2 for cue-only baselines and tests that distinguish intended and shortcut rules. Apply the diagnostic logic to a small tabular simulator; image-model training is not required. An input edit is a model stress test, not automatically an identified real-world causal intervention.