What Machine Learning Really Is
Traditional programming: you write the rules, the computer applies them to data. Machine learning flips it: you give the computer examples (inputs with the right outputs) and it learns the rules, a function that maps inputs to outputs and works on examples it has never seen.
Here is the input (features), the prediction, and the parameters the algorithm adjusts. “Learning” means finding parameters that make predictions good on average.
The three kinds of learning
| Type | Data | Goal | Examples |
|---|---|---|---|
| Supervised | Inputs with labels | Predict for new | Spam detection, house prices, image classification |
| Unsupervised | Inputs without labels | Find structure | Customer segments, anomaly detection, compression |
| Reinforcement | An agent acting in an environment, getting rewards | Learn actions that maximise reward | Games, robotics, the RLHF step of LLM training |
Supervised learning splits further by the type of target:
- Regression: is a number (price, temperature, delivery time).
- Classification: is a category (spam/not spam, digit 0–9, which disease).
Self-supervised learning, where labels come from the data itself (predict the next word, fill in a masked word), is how large language models are pretrained. We’ll get there.
The training loop
Almost every ML method, from linear regression to GPT, follows the same loop:
flowchart LR D[Training data] --> M["Model f(x; θ)"] M --> P[Predictions ŷ] P --> L["Loss: how wrong?<br/>L(ŷ, y)"] L --> G["Gradients ∂L/∂θ"] G --> U["Update θ ← θ − η ∇L"] U --> M
- Model: a family of functions with parameters .
- Loss: one number measuring how bad the predictions are, such as squared error for regression or cross-entropy for classification.
- Optimiser: adjusts to reduce the loss, almost always some form of gradient descent.
Generalisation: the real goal
A model that memorises its training data is useless. Data is therefore split:
- Training set (~70–80%): used to fit parameters.
- Validation set (~10–15%): used to choose hyperparameters and models, and to stop training early.
- Test set (~10–15%): touched once at the end to estimate real-world performance.
Overfitting is doing great on training data and badly on new data (the model learned noise). Underfitting is doing badly on both (the model is too simple). Balancing the two is the bias–variance trade-off, covered in the classical ML chapter.
Why the maths matters
You can call model.fit() without maths. Interviews for ML roles, and debugging real models, need more:
- Linear algebra: data is matrices; models are matrix multiplications.
- Calculus: training is following gradients downhill.
- Probability and statistics: losses come from likelihoods; evaluation needs statistics.
- Optimisation: gradient descent and its variants (SGD, momentum, Adam).
The first chapter covers exactly these, with no more than ML needs.
How this module is organised
- Math foundations: vectors and matrices, derivatives and gradients, probability, optimisation.
- Classical ML: linear and logistic regression, regularisation, evaluation, trees and ensembles, SVMs, clustering and PCA.
- Deep learning: neural networks, backpropagation, training tricks, CNNs, RNNs.
- Transformers and LLMs: attention, the transformer, pretraining and fine-tuning, embeddings and RAG.
- ML system design: how ML products are built, deployed and monitored, plus interview case studies.
Check yourself
Predicting tomorrow's temperature (a number) from past weather is…
Grouping customers into segments without any labels is…
Why do we evaluate on a held-out test set instead of the training data?
Item 1 of 24 · updated 2026-10-12