AI & ML Quick Path Progress

All cheat sheets

Cheat sheet: metrics

Which number to look at, and what it hides.

Confusion matrix

  • TP: fraud caught. FN: fraud missed. FP: false alarm. TN: normal payment passed.
Two rows of small shapes for the fraud example. The first row shows the 20 real frauds: 15 solid squares for frauds caught and 5 dashed squares for frauds missed. The second row shows the 45 payments the model flagged: the same 15 solid squares for real frauds and 30 diamonds for false alarms. Three cards give the results: recall 15 divided by 20 is 0.75, precision 15 divided by 45 is about 0.33, and accuracy 965 divided by 1,000 is 0.965. Real frauds: 20 of the 1,000 payments 15 caught 5 missed Flagged by the model: 45 payments 15 real frauds 30 false alarms Recall 15 ÷ 20 = 0.75 Of the real frauds, how many were caught. Precision 15 ÷ 45 ≈ 0.33 Of the flagged payments, how many were real. Accuracy 965 ÷ 1,000 = 0.965 Looks high, yet 5 frauds were missed. Solid square = fraud caught. Dashed square = fraud missed. Diamond = false alarm. Numbers from the run in this lesson.
Out of 1,000 payments, 20 are fraud. The model flags 45 of them: 15 real frauds and 30 false alarms, and it misses 5 frauds. Recall asks "how much fraud did we catch?", precision asks "how many flags were real?", and accuracy hides both.

Accuracy, precision, recall, F1

  • Accuracy hides rare-class failure.
  • Precision: of what we flagged, how much was real. Recall: of what was real, how much we caught.
accuracy = (TP + TN) / all
precision = TP / (TP + FP)
recall = TP / (TP + FN)
F1 = 2 x precision x recall / (precision + recall)

The threshold

  • A threshold turns a probability into a decision.
  • Moving it trades precision against recall.
A graph with an S-shaped curve rising from 0 to 1 and a dashed horizontal line at 0.5 labelled threshold. Scores above the line lead to class yes and scores below to class no. Text says moving the threshold trades precision against recall. threshold 0.5 probability 1 0 → class "yes" class "no" ← From score to decision The model turns its score into a probability (the S-shaped curve). A threshold turns the probability into a decision. Moving the threshold trades precision against recall. Horizontal axis: the model's raw score. The curve is the standard logistic (sigmoid) shape.
The model turns a score into a probability along an S-shaped curve, and a threshold turns that probability into a decision.

Regression

  • MAE, RMSE, R squared.
A scatter of ten dots with a fitted line. Vertical orange segments from each dot to the line show the errors, called residuals. Text explains that MAE is the average gap, RMSE punishes big gaps more, and R squared says how much of the ups and downs the model explains. Regression error Dots = real values. Line = the model's guesses. Orange gaps = the errors (residuals). MAE: the average gap. RMSE: punishes big gaps more. R²: how much of the ups and downs it explains. Made-up points. Smaller MAE and RMSE are better; R² is better the closer it is to 1.
The error measures are all based on the gaps between the real values and the model's line. The points are made up.

Honest evaluation

  • Split before training; cross-validate; keep the test set out of tuning.
  • For time series use walk-forward splits.
Five rows of five blocks. In each row a different block is marked test and the other four train: round 1 tests on the first block, round 2 on the second, and so on. A note says to average the five scores and report the spread. 5-fold cross-validation: every part takes a turn as the test part Round 1 test train train train train Round 2 train test train train train Round 3 train train test train train Round 4 train train train test train Round 5 train train train train test Average the five scores and report the spread (for example 0.908 ± 0.009). One lucky split cannot fool you. The five blocks are five equal parts of the same data. The final test set stays untouched.
In cross-validation every part of the data takes a turn as the test part, and the scores are averaged, so one lucky split cannot fool you.

Drift

  • A population stability index (PSI) below 0.1 is stable, 0.1 to 0.25 needs a look, above 0.25 is a large shift.
Two panels. Data drift: two bell curves, the training data and the live data, with the live one shifted to the right, meaning the inputs have changed. Concept drift: a scatter-free plot with two lines for the same input, the relationship before and the relationship now, which differ, meaning the right answer for the same input has changed. Data drift The inputs change. training data live data, shifted Concept drift The right answer for the same input changes. the relationship before the relationship now same inputs, different answers Made-up curves to show the idea. Monitoring compares live data with the training data (and live results with the truth).
Data drift means the inputs changed; concept drift means the right answer for the same input changed. The curves are made up.

Language models and applications

  • Perplexity compares models only when they use the same tokeniser and text.
  • An eval set with thresholds blocks a bad release.
  • Compare group rates for fairness.