Regression, classification and model evaluation
Predict continuous or categorical outcomes, calculate evaluation metrics and explain hyperparameter choices.
What you need to be able to do
- explain linear regression using predictor/response, slope, intercept and R²;
- explain K-NN and decision-tree classification from labelled data;
- calculate and interpret accuracy, precision, recall and F1;
- explain how hyperparameter tuning can lead toward overfitting or underfitting.
Rapid Recall Deck
Attempt each card first. If a term is new, flip and study it, then answer it again without looking. Mark only secure recall as “Know it”.
Read a regression equation
Energy-use model
predicted_kWh = 120 + 8 × hours_used
Identify predictor and response, then interpret slope 8 and intercept 120.
Predictor: hours_used. Response: predicted kWh. The model predicts about 8 additional kWh for each extra hour-used unit. The intercept predicts 120 kWh at hours_used=0; that interpretation is only meaningful if zero is sensible for the data/context.
Choose the output type
R²
Model A has R²=0.82 and Model B has R²=0.31 on comparable evaluation data. What can you cautiously infer?
Model A explains more observed response variation through its fitted relationship. R² alone does not prove causation, fairness or overall suitability.
Regression or classification?
House price; benign/malignant tumour; tomorrow's temperature; spam/not spam.
Regression, classification, regression, classification.
K-NN and decision trees
K-NN
A new user's five nearest labelled neighbours contain four “liked” and one “disliked”. Under majority voting, predict and explain.
Predict “liked”. K-NN compares the new point to labelled training examples, selects K nearby examples and derives the category from their labels.
Decision tree
Why can symptom-based medical diagnosis fit a decision tree?
The tree can learn symptom/feature splits from labelled cases and apply a sequence of conditions to reach a categorical diagnosis. Tree complexity still needs tuning.
Calculate evaluation metrics
Confusion matrix
| Actual + | Actual − | |
|---|---|---|
| Predicted + | TP=40 | FP=10 |
| Predicted − | FN=20 | TN=130 |
Calculate accuracy, precision and recall.
Accuracy=(40+130)/200=0.85. Precision=40/(40+10)=0.80. Recall=40/(40+20)≈0.667.
The cost of errors changes the useful metric
F1
Use precision 0.80 and recall 0.667.
F1 = 2 × precision × recall / (precision + recall)
F1≈0.727.
Medical screening
If missing a true disease case is especially harmful, which metric deserves strong attention?
Recall, because it measures the proportion of actual positive cases correctly identified; low recall means many false negatives.
Generalization rather than memorization
K too small / too large
Explain the overfit/underfit risk in K-NN.
Very small K can be sensitive to noise and overfit; very large K can smooth away useful local structure and underfit. Validation evidence helps choose K.
Training vs validation
99% training, 72% validation versus 61% training, 59% validation. Diagnose each.
99/72 suggests overfitting. 61/59 suggests underfitting. Tuning model complexity, features and training settings should target better generalization.
Metrics must fit the real outcome
Paper 1 mini-set
1. Precision=.75, recall=.60: calculate F1. 2. Explain how K-NN predicts a category. 3. Explain hyperparameter tuning and overfitting.
F1≈0.667. K-NN uses labels of nearby examples under a distance/K rule. Hyperparameters control model/training behaviour; validation-based tuning helps avoid settings that memorize training noise.
Visionary Studios
Why is “highest accuracy” not a sufficient model-selection rule for its generative-image system?
The case requires output quality, computational efficiency, training stability, flexibility/scalability and consistency—not one classification-accuracy score. Selection must use evidence aligned to those outcomes.
Finish the learning cycle
Case study / exam preparation
Add evidence to the Visionary Studios model-comparison matrix using the official evaluation factors.
Paper 1 — short practice
Recalculate accuracy, precision, recall and F1 on two small confusion matrices.
Case-study checkpoint
Explain one overfitting and one underfitting diagnosis without notes.