Sapienza Università di Roma · BSc Mathematics of Artificial Intelligence
Applicazioni Informatiche del Machine Learning
How to build a machine learning system, and how to know whether it works.
One topic per lecture, and every lecture stands on its own.
Ninety minutes, in four blocks.
The one object the method rests on, derived rather than quoted — because the method does not make sense without it, and because the derivations are what you still have in five years when the libraries have changed.
How it works, what its hyperparameters do, the conditions under which it fails, and a worked example with real numbers from real data — every figure on every slide reproduced by a script in this repository.
The variants, when to prefer each, and what practitioners actually reach for — which is not always what the textbook presents first.
What is in it, what to run, and what to change to see something move. You run it yourself afterwards; the lecture is not a live coding session.
Ten minutes at the top of each lecture place it in the arc: what we can already do, what we cannot, and which of the two today’s method changes.
You will write machine learning code with an assistant — if not in this course, then in the thesis after it and in the job after that. So the course is explicit about how.
| # | Step | Who |
|---|---|---|
| 1 | Specify — the input, the output, the constraint, the check | you |
| 2 | Generate — and then stop, before running anything | the assistant |
| 3 | Read — as a reviewer, not as an author | you |
| 4 | Test — against a case whose answer you already know | you |
| 5 | Verify — that the number means what it appears to mean | you |
Steps 3–5 are the course. Step 2 is the part that is free.
Machine learning fails silently. A bug in a training loop does not crash — it returns a plausible number:
model.eval() leaves dropout active during evaluation.optimizer.zero_grad() accumulates gradients with no error.Every one of these runs. Every one produces a number. Each is taught in the lecture where it belongs — leakage in Lecture 2, imbalance in Lecture 3, and all three PyTorch failures — the optimiser pair and batch averaging — in Lecture 10, as a property of the method rather than as a trap.
Short version: the mathematics of a third-year BSc in Mathematics of Artificial Intelligence, and enough Python to read code critically. If you are missing something, none of it takes long to fix — and everything below is a pointer, not a reading list to complete before the first lecture.
These are not warm-up exercises. Each one is a thing you will actually be asked to do, in the lecture where it appears. Try them before deciding you need to revise anything.
$\mathbf{X}$ is $m \times n$ and $\boldsymbol\theta$ is $n \times 1$. What is the shape of $\mathbf{X}\boldsymbol\theta$, and why is $\mathbf{X}^{\mathsf T}\mathbf{X}$ square?
Lecture 2, first ten minutes.
Differentiate $\lVert\mathbf{X}\boldsymbol\theta - y\rVert^2$ with respect to $\boldsymbol\theta$. Then say what has to be true of the Hessian for the stationary point to be a minimum.
Lecture 2. This is the derivation, not a preliminary to it.
When is $\mathbf{X}^{\mathsf T}\mathbf{X}$ not invertible? Answer in terms of the columns of $\mathbf{X}$.
Lecture 2, and again in Lecture 5 when ridge repairs it.
$A$ and $B$ each have variance $\sigma^2$ and correlation $\rho$. What is $\operatorname{Var}\!\left(\tfrac{A+B}{2}\right)$?
Lecture 7. This single calculation explains bagging, random forests and extra-trees.
What does a 95% confidence interval mean — and what does it not mean?
Lecture 2, on the final test score.
a has shape (100, 3),
b has shape (3,). What does a - b
compute, and what shape comes out? Now b has shape
(100,) — what happens?
Every lecture. Silent broadcasting is silent.
Given a DataFrame df, select the rows where
df["x"] > 5, keeping only columns "a" and
"b". Then count how many values in "a" are
missing.
Lecture 1, in the notebook.
Read this traceback out loud and say which line of
your code caused it, and why:
ValueError: Input X contains NaN.
Lecture 2, the first time preprocessing meets a missing value.
| What you need | First needed | If you are missing it |
|---|---|---|
| Linear algebra matrix products, transpose, inverse, rank, column space, orthogonality, positive semi-definiteness, SVD |
L2 |
3Blue1Brown, Essence of Linear Algebra
for the geometric intuition — about three hours, and it is the
intuition the Lecture 2 derivation assumes. For depth: MIT 18.06 (Strang). |
| Multivariable calculus partial derivatives, gradients, the chain rule, Hessians, convexity |
L2 | 3Blue1Brown, Essence of Calculus, then chapter 5 of Mathematics for Machine Learning (free PDF) for vector calculus in exactly the notation we use. |
| Probability and statistics expectation, variance, covariance, correlation, independence, sampling, confidence intervals |
L2, L5, L7 |
Seeing Theory (Brown)
is a visual refresher in an afternoon. For depth: MIT 18.05, or chapter 6 of Mathematics for Machine Learning. |
If you are on this degree programme you almost certainly have all three. The self-check above is a faster way to confirm that than reading the list.
| What you need | First needed | If you are missing it |
|---|---|---|
| Python functions, lists and dicts, comprehensions, imports, reading a traceback |
L1 | The official Python tutorial, sections 3–6. A weekend from a standing start; an evening if you know another language. |
| NumPy arrays, shapes, indexing, axes, and broadcasting |
L1 | NumPy: the absolute basics, then the broadcasting rules — read that second page twice. It is the single most common source of code that runs and is wrong. |
| pandas DataFrame, Series, selection, missing values |
L1 | 10 minutes to pandas. Optimistically named, but an hour genuinely does it. |
| matplotlib enough to draw a histogram and a scatter plot |
L1 | The pyplot tutorial. Twenty minutes; you will not need more than this in the whole course. |
| Google Colab running cells, restarting the runtime, reading a traceback |
L1 | Colab’s own introduction. Ten minutes. Bring a Google account to the first lecture. |
| scikit-learn the estimator API — fit,
transform, predict |
L2 | Helpful but not required — taught from scratch in Lecture 2. Lecture 1 fits nothing at all: looking properly at data before modelling it is not a preliminary, it is what decides whether the model can work. If you are curious: Getting started. |
| PyTorch | L10 | Not required. Taught from first principles in Lecture 10 — tensors, autograd, and the training loop written out in full before any of it is hidden behind a helper. If you insist: the official basics. |
Helpful, not assumed. The course starts from a problem and a dataset on the first day and builds everything from there.
Parts II–VI assume nothing beyond what Part I established. Neural networks arrive in Lecture 9, once the classical models have been covered properly.
No production systems, no deployment infrastructure, no build tooling. Notebooks throughout.
The notebooks are written for you. What is examined is whether you can read them — say what a cell does, what it measures, and what would break if an argument changed.
Twenty-four lectures on Tuesdays and Wednesdays, from 6 October 2026 to 12 January 2027.
| October 2026 | ||
|---|---|---|
| 01 | What machine learning is, and how we will work | |
| 02 | The end-to-end project | |
| 03 | Classification and its metrics | |
| 04 | Training models | |
| 05 | Regularisation and the bias–variance trade-off | |
| 06 | Decision trees | |
| 07 | Ensembles and random forests | |
| 08 | Dimensionality reduction and unsupervised learning | |
| November 2026 | ||
| 09 | Neural networks, from the perceptron up | |
| 10 | PyTorch | |
| 11 | Training deep networks | |
| 12 | Convolutional networks | |
| 13 | Transfer learning | |
| 14 | Detection and segmentation | |
| 15 | Time series | |
| 16 | Recurrent networks | |
| December 2026 | ||
| 17 | Text | |
| 18 | Attention and transformers | |
| — | Immacolata — the university is closed | |
| 19 | Information retrieval: the lexical foundation | |
| 20 | Information retrieval: dense retrieval | |
| 21 | Recommender systems: from ratings to factors | |
| 22 | Recommender systems: neural, and evaluated honestly | |
| 23 | Vision transformers and multimodal retrieval | |
| 24 Dec – 6 Jan | — | Christmas break |
| January 2027 | ||
| 24 | Generation, retrieval-augmented systems, and where this leaves you | |
The material is not published in advance. A lecture’s slides, notebook and notes appear on this page at 11:30 on the day that lecture is taught, half an hour before it begins, and stay there for the rest of the course.
Twenty-four lectures in six parts. Each lecture’s slides, notebook and notes appear on its own card at 11:30 on the day it is taught.
What machine learning is, and how we will work
· 12:00–14:00 · Aula C
The end-to-end project
· 12:00–14:00 · Aula C
Derivation · Least squares and the normal equation
Classification and its metrics
· 12:00–14:00 · Aula C
Derivation · Imbalance, and the non-monotonicity of precision
Training models
· 12:00–14:00 · Aula C
Derivation · Gradient descent
Regularisation and the bias–variance trade-off
· 12:00–14:00 · Aula C
Derivation · The bias–variance decomposition
Decision trees
· 12:00–14:00 · Aula C
Derivation · Impurity: Gini and entropy
Ensembles and random forests
· 12:00–14:00 · Aula C
Derivation · The variance of an average of correlated predictors
Dimensionality reduction and unsupervised learning
· 12:00–14:00 · Aula C
Derivation · PCA via the SVD; Johnson–Lindenstrauss
Neural networks, from the perceptron up
· 12:00–14:00 · Aula C
Derivation · What a layer computes
PyTorch
· 12:00–14:00 · Aula C
Derivation · Backpropagation as reverse-mode automatic differentiation
Training deep networks
· 12:00–14:00 · Aula C
Derivation · Variance propagation and weight initialisation
Convolutional networks
· 12:00–14:00 · Aula C
Derivation · Weight sharing, equivariance and memory
Transfer learning
· 12:00–14:00 · Aula C
Detection and segmentation
· 12:00–14:00 · Aula C
Derivation · IoU’s vanishing gradient; mAP
Time series
· 12:00–14:00 · Aula C
Derivation · Stationarity, differencing and autocorrelation
Recurrent networks
· 12:00–14:00 · Aula C
Text
· 12:00–14:00 · Aula C
Derivation · Softmax, cross-entropy and logits
Attention and transformers
· 12:00–14:00 · Aula C
Derivation · Scaled dot-product attention
Information retrieval: the lexical foundation
· 12:00–14:00 · Aula C
Derivation · Evaluating a ranking: MRR, AP, NDCG
Information retrieval: dense retrieval
· 12:00–14:00 · Aula C
Recommender systems: from ratings to factors
· 12:00–14:00 · Aula C
Derivation · Matrix factorisation, and its relation to the SVD
Recommender systems: neural, and evaluated honestly
· 12:00–14:00 · Aula C
Vision transformers and multimodal retrieval
· 12:00–14:00 · Aula C
Derivation · The contrastive objective and its temperature
Generation, retrieval-augmented systems, and where this leaves you
· 12:00–14:00 · Aula C
Each lecture derives the one object its method rests on. Not a parallel theory course: every derivation below does visible work on the method taught beside it, and they are 40% of the written paper.
The written examination carries the mark. The oral is optional, short, and can move that mark in either direction.
Two hours, closed book, no formula sheet. Three parts: the derivations, choosing a method for a stated situation, and reading results — as technical exercises, closed choices with their reason, and short open answers.
Marked out of 30, pass at 18. From the written alone, the mark recorded is capped at 27.
Seven to ten minutes. Three questions, on any topic from the course.
No notes, no computer. Open to anyone who passed the written.
Yes — and this course is better suited to one than most applied courses, for a specific reason.
Three rules keep it honest.
train_test_split would test what a
docstring is for. Syntax errors in handwritten code cost nothing;
logic errors cost everything.This is why closed book costs you nothing here. Each of the eighteen derivations is one you have performed — and a result you can rebuild in three lines is not a result you need to have memorised.
What a written examination cannot see is whether the reasoning on the page is yours. That is what the oral is for — and it is why it is short, and why it can go to any part of the course.
The three parts below are weighted within the paper. The paper carries your mark: up to 27 on its own, and up to 30 if you sit the oral.
Every paper mixes three forms of question, and the parts below say what each one is about rather than what shape it takes: technical exercises worked on the page — a derivation, a gradient, an arithmetic check on a stated table; closed questions, where you choose between two or three stated options; and open questions answered in a few sentences. A closed choice is rarely enough on its own: where a question asks for the reason as well as the choice, both are needed for full marks.
| Part | What it asks | Weight of the paper | Time |
|---|---|---|---|
| A · The derivations | Derive, state, apply. The eighteen objects developed in the lectures — the normal equation, the bias–variance decomposition, variance reduction by averaging, reverse-mode differentiation, cross-entropy, NDCG, and the rest. | 40% | ~48 min |
| B · Choosing a method | A situation in four lines: this data, this constraint, this requirement. Which method, why that one rather than the obvious alternative, and what evidence would make you change your mind. Some questions supply a short code excerpt and ask what it would take for its reported number to be trustworthy. | 35% | ~42 min |
| C · Reading results | Plots and tables — learning curves, per-fold scores, a confusion matrix, a precision/recall curve, a ranking. Say what they show, what they do not show, and which way the number moves if you change the stated thing. | 25% | ~30 min |
One from each part, at the intended level and scale — each is calibrated to the time budget above.
Illustration only. These three show the kind of thing each part asks and roughly how much of it. They are not a template, not a syllabus, and not a promise: the questions on the paper you sit may differ in form, in topic, and in how they are put.
Two regressors each have variance $\sigma^2$ and are correlated with coefficient $\rho$.
A colleague has 4,000 labelled rows and sixty numeric features, many of them near-duplicates of one another. Every prediction has to be justified to a regulator.
They send you this program, and the number it printed.
best = None
for a in [0.01, 0.1, 1, 10, 100]:
m = Ridge(alpha=a).fit(X_train, y_train)
s = root_mean_squared_error(y_test, m.predict(X_test))
if best is None or s < best[1]:
best = (a, s)
print(f"best alpha={best[0]}, test RMSE={best[1]:,.0f}")
Every part has a determinate answer — ridge, because the near-duplicate features make $\mathbf{X}^{\mathsf T}\mathbf{X}$ ill-conditioned and the regulator rules out the forest; the test set; (i); a cross-validated search on the training data, scored once on the test set. Nothing here rewards a well-phrased opinion, and none of it can be answered without knowing what a validation set is for.
Two teams report the following for the same dataset.
| Team | Training RMSE | 10-fold CV RMSE |
|---|---|---|
| A | $0 | $68,574 |
| B | $68,233 | $68,282 |
Optional. Three questions, answered aloud, on any topic the course covered — there is no separate syllabus for it, and no list of questions to learn.
Nothing is collected and nothing is graded as an artefact. The notebooks are examinable as experience: you are expected to be able to account for what they do and why, without the code in front of you.
Note what is absent: there are no marks for a notebook that runs. Evidence earns marks.
Aurélien Géron, Hands-On Machine Learning with Scikit-Learn and PyTorch, O’Reilly, 2025 — Chapters 1–16, covering Lectures 1–18 and 23–24.
Lectures 19–22 — information retrieval and recommender systems — sit outside the book and are taught from the lecture notes. They are examinable on the same terms as everything else, and for those four lectures the notes below are the primary source — not a supplement to a chapter, because there is no chapter.
Written notes exist for every lecture — the Notes (PDF) button that appears on each card above on the day of its lecture. For the other twenty they set out the lecture’s argument at length beside the chapter it is taught from; the four listed here are the ones with no chapter behind them.
| Extended lecture notes | Dataset |
|---|---|
| 19 · Information retrieval: the lexical foundation | SciFact (BEIR) |
| 20 · Information retrieval: dense retrieval | SciFact (BEIR) |
| 21 · Recommender systems: from ratings to factors | MovieLens 1M |
| 22 · Recommender systems: neural, and evaluated honestly | MovieLens 1M |
| Chapter | Lectures |
|---|---|
| 1 · The machine learning landscape | 1 |
| 2 · End-to-end project | 1, 2 |
| 3 · Classification | 3 |
| 4 · Training models | 4, 5 |
| 5 · Decision trees | 6 |
| 6 · Ensembles and random forests | 7 |
| 7 · Dimensionality reduction | 8 |
| 8 · Unsupervised learning | 8 |
| 9 · Introduction to artificial neural networks | 9 |
| 10 · Building networks with PyTorch | 10 |
| 11 · Training deep networks | 11 |
| 12 · Deep computer vision | 12, 13, 14 |
| 13 · Sequences | 15, 16 |
| 14 · NLP with RNNs and attention | 17, 18 |
| 15 · Transformers | 18, 23, 24 |
| 16 · Vision and multimodal transformers | 23, 24 |
| Lecture notes · Information retrieval | 19, 20 |
| Lecture notes · Recommender systems | 21, 22 |
M opens the menu, S opens the
speaker notes, C toggles the chalkboard, F
goes full screen.