Coders In Hoods
  • Courses
  • Roles
  • Blog
  • Setup

Coders In Hoods AI Academy

Every course is free. Sign in to start, and your progress, quiz scores and bookmarks follow you.

AI Academy

  • Courses
  • Paths
  • Setup guides
  • How we teach

Role roadmaps

  • AI Engineer
  • Forward Deployed Engineer
  • Machine Learning Engineer
  • All roles

Coders In Hoods

  • The agency
  • Coaching for teams
  • Blog
  • LinkedIn
  • X (Twitter)

Contact

codersinhoods@gmail.com

© Coders In Hoods · since 2019

Course overview

Machine Learning Foundations for LLM Work

Free · sign in to start and track progress

1 · Learning from data

  • 1Problems, data and baselines
  • 2Train, validation, test and leakage
  • 3Loss functions and gradient descent

2 · Classifiers and generalisation

  • 4Logistic regression, step by step
  • 5Metrics, thresholds and calibration

    Exercise answers

    • Answer: Curves, a cost-based threshold and a calibration check
    • Answer: Boosted trees: ranking against calibration
  • 6Overfitting, regularisation and cross-validation

3 · The maths the later courses assume

  • 7Probability for evaluation
  • 8Standard errors, intervals and paired tests
  • 9Vectors, dot products and embeddings
  • 10A small neural network from scratch
CapstoneTicket triage you can defendReference implementation

Module 2 · Classifiers and generalisation · Lesson 5

Metrics, thresholds and calibration

The confusion matrix and the metrics that read off it, ROC and precision–recall curves, a threshold chosen from the cost of each kind of mistake rather than 0.5 by habit, and the calibration check that tells you whether a probability of 0.8 means 80%.

80 min 2 videos 3 exercises 7-question quiz Answers
Setup for the exercises:Install Claude CodePython with uvThe Hollowbrook ticket data

By the end of this lesson you can

  • Fill a confusion matrix from predictions and labels, and compute accuracy, precision, recall (TPR), specificity (TNR), false-positive rate and F1 by hand
  • Draw ROC and precision–recall curves from scores, explain what AUC measures, and say when the PR curve is the more informative of the two
  • Derive the cost-minimising threshold from the cost of a false positive and a false negative, and check it against a threshold search on validation data
  • Build a reliability diagram, compute expected calibration error and the Brier score, and repair a miscalibrated model with Platt scaling or isotonic regression
  • Explain why a classifier or judge that ranks well but is miscalibrated misleads every decision built on its probabilities

On this page

  • The four kinds of outcome
  • The urgency model at three thresholds
  • Curves: every threshold at once
  • Choosing the threshold from costs
  • Is 0.8 really 80%?
  • The urgency model, and a tempting way to break it
  • Repairing it
  • Why this matters beyond ticket triage
  • Connections
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01The four kinds of outcome
  2. 02Curves: every threshold at once
  3. 03Choosing the threshold from costs
  4. 04Is 0.8 really 80%?
  5. 05Why this matters beyond ticket triage
  6. 06Connections
  7. 07Summary

Sources & further reading

  • On Calibration of Modern Neural NetworksPaper · Guo, Pleiss, Sun, Weinberger · 2017The paper that made calibration a standard check again. Section 2 defines reliability diagrams and expected calibration error exactly as this lesson uses them; section 4 introduces temperature scaling, a one-parameter cousin of Platt scaling.
  • Predicting Good Probabilities With Supervised LearningPaper · Niculescu-Mizil, Caruana · 2005Which model families come out calibrated and which do not, and the comparison of Platt scaling with isotonic regression. Sections 2 and 3 are the reference for the stretch exercise.
  • Classifier Calibration: A survey on how to assess and improve predicted class probabilitiesPaper · Silva Filho, Song, Perello-Nieto, Santos-Rodriguez, Kull, Flach · 2021The current survey. Section 3 on evaluating calibration (including the limits of ECE with few samples) and section 5 on calibration methods.
  • The Precision-Recall Plot Is More Informative than the ROC Plot When Evaluating Binary Classifiers on Imbalanced DatasetsPaper · Saito, Rehmsmeier · 2015The case, with simulations, for reading the precision–recall curve when positives are rare. Read the introduction and the "ROC and PR" results.
  • The harms of class imbalance corrections for machine learning based prediction modelsPaper · Carriero, Luijken, de Hond, Moons, van Calster, van Smeden · 2024Simulation evidence that reweighting or resampling to "fix" imbalance wrecks calibration while barely changing discrimination, which is exactly what the core exercise reproduces.
  • Classification: Thresholds and the confusion matrix (Machine Learning Crash Course)Lab research · GoogleA short interactive pass over moving a threshold and watching the four cells change, if you want to see it before computing it.
  • Metrics and scoring: quantifying the quality of predictions (scikit-learn user guide)Docs · scikit-learnSection 3.4.4 on classification metrics (`confusion_matrix`, `precision_recall_curve`, `roc_auc_score`, `brier_score_loss`), and the companion section 1.16 on `CalibratedClassifierCV`.
Free · sign in to start

Sign in to keep reading.

Free, no card. We use your account to save progress, quiz scores, bookmarks and occasionally send updates from our team.

  • 7 more sections
  • 3 hands-on exercises
  • A 7-question quiz
  • Progress, quiz scores and bookmarks