7 routes42 sections324 units

Unit 5.3 · about 3 h

162 / 324

ROC AUC, average precision, log loss and Brier score

Ranking scores compare models across thresholds, but only proper scores judge the probabilities you will later threshold, weight or abstain on.

  • derive
  • measure

You can now

  • Derive ROC AUC as the pairwise ranking probability and average precision as the precision-recall summary.
  • Explain why ROC AUC is prevalence-independent while average precision moves with the base rate.
  • Compute log loss and Brier score by hand and state what each one punishes beyond ranking.

Covers

  • ROC AUC, average precision, log loss and Brier score

Study, in this order

1 steps

  1. ROC, precision-recall, log loss and Brier score
    scikit-learn - model selection and evaluation route

    Sections 3.4.4.15.1 (binary ROC with predict_proba[:, 1] or decision_function; breast-cancer AUC 0.99), 3.4.4.9 (average_precision_score and precision_recall_curve), 3.4.4.12 (log loss) and 3.4.4.18 (Brier score, binary range and calibration note)

    Depth · Skip multilabel ranking metrics (3.4.5) and DET curves unless your task needs them.

Focus on

  • Pass the positive-class column predict_proba(X)[:, 1] (classes_[1]) or decision_function to roc_auc_score, never hard predictions.
  • The docs' 0.99 breast-cancer AUC is a demonstration, not a result: the snippet re-scores its own training data.
  • Average precision summarizes the PR curve and falls with prevalence; ROC AUC conditions within each class and does not move.
  • Log loss punishes one confident error without bound; Brier stays bounded and mixes calibration with discrimination.

Reproduce closed-book

Closed-book, compute ROC AUC by pairwise comparison on y [0,0,1,1] with scores [0.1,0.4,0.35,0.8] to get 0.75 (3 of 4 positive-negative pairs ordered), plus log loss 0.47 and Brier 0.16, and list the ROC points (0,0), (0,0.5), (0.5,0.5), (0.5,1), (1,1).

Traps

  • Feeding predict() labels into roc_auc_score. Hard labels give one elbow and a collapsed AUC; pass scores.
  • Quoting the in-sample 0.99 AUC from the docs snippet as model quality. It re-scores training data.
  • Treating ROC AUC as a calibration check. A model can rank perfectly while its probabilities are badly miscalibrated.

Practice

Hand-check ROC, AUC and Brier against sklearn

Match your hand computation on y [0,0,1,1] with scores [0.1,0.4,0.35,0.8] (AUC 0.75, AP 0.833) against roc_auc_score, average_precision_score and brier_score_loss, then reproduce the confusion_matrix_at_thresholds table (tns [2,1,1,0], tps [1,1,2,2])

All three numbers were verified with sklearn 1.9. Recompute AP by hand from the PR points before checking.

Self-test

  1. What does AUC 0.75 mean as a pairwise statement on the reproduce example?

  2. Prevalence drops 10x at fixed score distributions. What happens to ROC AUC and to average precision?

  3. Why does log loss explode on one confident error while Brier stays bounded?

  4. roc_curve returns thresholds starting at inf. Why is inf not an operating threshold?

Completion criterion

Stop when

Your hand AUC, AP, log loss and Brier match sklearn to 3 decimals, and you can say which metric moves when prevalence shifts.

Mark passed, then open 5.4 Only mark this when you can do it without notes.

Leads to

Comes after

Resources for this unit

  • scikit-learn - model selection and evaluation route
    scikit-learnprimarycourse
    Follow Cross-validation, Hyperparameter tuning, Decision threshold tuning, Metrics and scoring, Probability calibration, Validation curves, Permutation importance and Common Pitfalls. Retain raw predictions and independently hand-check central metrics.

Also in this section

  • ISLP - resampling and multiple testing
    James, Witten, Hastie, Tibshirani and Taylorrequiredtheory
    Use Chapter 5 and the relevant selection-history parts of Chapter 13 with their Python labs. Connect resampling to uncertainty and multiplicity without repeating the full statistics stage.
  • Classical ML Scientific Investigation
    Roadmap-Finalreferenceassessment
    Use Core requirements, architecture constraints, Milestones A-F and failure injection as the standard for end-to-end evidence. The full project remains a later capstone route.
  • D2L - Environment and Distribution Shift
    D2L authorssupporttheory
    Read 4.7, then construct one controlled covariate, label and concept shift. Record what changes, which signal detects it and what response the evidence supports.
  • Deep-ML candidate - evaluation problems
    Deep-MLoptionalpractice
    After the platform admission check, use at most one of 18 K-Fold CV, 260 Expected Calibration Error, 276 ROC, 277 AUC or 840 Stratified K-Fold. Hand-checked local metrics remain the evidence.
  • SciPy - Resampling and Monte Carlo methods tutorials
    SciPy developersreferencereference
    Work the notebooks linked from this page: Tutorial 3 (The Bootstrap) with scipy.stats.bootstrap, including paired=True, and Tutorial 2b (Paired-Sample Permutation Tests) with permutation_test and permutation_type='samples'. Keep one resampling index stream across compared models.
  • El-Yaniv and Wiener - On the Foundations of Noise-free Selective Classification
    JMLRreferencereference
    Read the Abstract and Section 2 (Preliminary Definitions: Definitions 1 and 2 for coverage and selective risk) for the risk-coverage tradeoff. Stop before the noise-free learning bounds.

Quick find

Search Michi

Type to search every route, section, unit, topic and resource.

Enter opens the first result Esc closes

Reference

Keyboard shortcuts

n
Continue to the first unit not passed
j / k
Next / previous unit
1 2 3
Toggle learned, practised, passed
/
Open search
?
Show this help
Esc
Close open panels