Training & Evaluation
CSC3104 · Lab

Metrics from a confusion matrix

Fill in a confusion matrix and watch accuracy lie on imbalanced data. Then read four sets of training curves the way an examiner expects you to.

  1. 1 · Predict0/1
  2. 2 · Experiment0/2
  3. 3 · Explain0/1
  4. 4 · Code it0/2
  5. 5 · Challenge
  6. 0/4 tasks done

Predict first

Commit to a guess before you touch anything. Being wrong here is how it sticks.

TP = 40, FP = 10, FN = 20. What's the F1 score? (2 dp)

Experiment

Move the controls and watch the outputs. Goals tick off automatically when you reach them.

Metrics from a confusion matrix

Accuracy
97.0%
Precision
80.0%
Recall
66.7%
F1
72.7%
Specificity
98.9%

Read the curves

Training loss keeps falling while validation rises after ~30% of training: overfitting (high variance). Augment, regularise, stop early, or get more data.

Explain it

Put what you saw into words. This is what the exam will ask you to do.

How do you diagnose overfitting vs underfitting from loss curves, and what do you do about each?

Code it

Write real code against real data. Python and SQL run right here in your browser and hidden tests check your work; the AI reviews it like an examiner.

Pythonwarm-up

Metrics from predictions

Write metrics(y_true, y_pred) (NumPy arrays of 0/1) returning a dict with tp, fp, fn, tn, accuracy, precision, recall, f1 — use 0.0 when a denominator is 0.

Ctrl/⌘ + Enter to run

Challenge

Fixed variations, a new problem every day, and unlimited AI challenges built from your current settings.

Harmonic Mean F1 Score

On a medical test set: TP = 40, FP = 10, FN = 20, TN = 930. What is the F1 score (as a decimal between 0 and 1, rounded to 2 decimals)?