AI-101 · Foundations of AI · Module 3 of 3

Machine Learning Fundamentals

Supervised, unsupervised, and reinforcement learning — the mathematical intuition behind gradient descent, overfitting, bias-variance tradeoff, and model evaluation that every AI practitioner must understand.

TrackUndergraduate
LevelIntroductory
Duration~3 hours
PrerequisitesAI-101 M1 & M2
Read Timecalculating…
What Is Learning?

The Three Paradigms of Machine Learning

Machine learning is the study of algorithms that improve automatically through experience. Rather than programming explicit rules, we provide data and an objective, and the algorithm adjusts its internal parameters to minimise error. This shifts the engineering effort from rule-writing to dataset curation and objective design — a profound change in how software is built.

Supervised learning trains on labelled input-output pairs (x, y) and learns a function f such that f(x) ≈ y. Classification (discrete y: spam/not-spam) and regression (continuous y: house price) are the two main types. Unsupervised learning finds structure in unlabelled data — clusters, dimensionality reductions, generative models. Reinforcement learning trains an agent to maximise cumulative reward through trial and error in an environment — the paradigm behind AlphaGo, ChatGPT's RLHF tuning, and robotic control.

Gradient Descent: The Engine of Modern ML

Almost every modern ML system trains via gradient descent. The intuition: imagine you are blindfolded on a hilly landscape and want to reach the lowest valley. Your only information is the slope beneath your feet. You take a small step in the downhill direction, feel the new slope, and repeat. That's gradient descent — iteratively adjusting parameters in the direction that reduces the loss function.

The loss function L(θ) measures how wrong the model is. For classification, cross-entropy loss is standard. For regression, mean squared error. The gradient ∇L(θ) points in the direction of steepest increase. We update: θ ← θ − η∇L(θ), where η (eta) is the learning rate — a critical hyperparameter. Too large: oscillates or diverges. Too small: converges too slowly or gets trapped in local minima.

The Bias-Variance Tradeoff

Every model's error has two sources. Bias is systematic error from underfitting — a model too simple to capture the true relationship. A linear model fit to non-linear data has high bias. Variance is sensitivity to fluctuations in training data — an overly complex model that memorises noise. The total expected error = Bias² + Variance + irreducible noise. Reducing bias often increases variance and vice versa.

Overfitting: excellent training performance, poor generalisation. Signs: training loss much lower than validation loss. Remedies: more data, regularisation (L1/L2), dropout, simpler model, early stopping. Underfitting: poor training and validation performance. Signs: both losses are high. Remedies: more complex model, more features, less regularisation, more training.

Model Evaluation: What Accuracy Hides

Accuracy (correct predictions / total) is misleading for imbalanced datasets. A model predicting "no cancer" 100% of the time achieves 99% accuracy on a dataset where 1% have cancer — but is completely useless. The full picture requires the confusion matrix and derived metrics:

Precision = TP/(TP+FP): of all positive predictions, how many were right? Recall = TP/(TP+FN): of all actual positives, how many did we catch? F1 score = 2 × (Precision × Recall)/(Precision + Recall): harmonic mean balancing both. AUC-ROC: area under the receiver operating characteristic curve — model's ability to discriminate at any threshold.

Which Metric Matters?

The choice depends on the cost of errors. In cancer screening, false negatives (missed cancer) are catastrophic — optimise recall. In spam filtering, false positives (blocking legitimate email) are more annoying — optimise precision. There is no universally correct metric. Metric choice is a values decision about which errors are acceptable.

← Search & Problem Solving AI Ethics →