Sapienza Università di Roma · BSc Mathematics of Artificial Intelligence

Applications of
Machine Learning

Applicazioni Informatiche del Machine Learning

How to build a machine learning system, and how to know whether it works.

Load
22 lectures
Year
Third year, BSc
When
Tue & Wed · 12:00–14:00 · from 6 Oct 2026
Where
Aula 1, Via De Lollis · from 17 Nov 2026
Teaching language
Italian · materials in English
Lecturer
Fabrizio Silvestri
Google Classroom
Join the class

The organising principle

One topic per lecture, and every lecture stands on its own.

Each lecture is the mathematics, the method, and a notebook that implements it. If you miss a lecture, you read its slides and its notebook and you are caught up — you never have to reconstruct anything from the lecture before it.

Each lecture, in four blocks.

The mathematics

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.

The method

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.

Further ground

The variants, when to prefer each, and what practitioners actually reach for — which is not always what the textbook presents first.

The notebook

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.

The opening of each lecture places it in the arc: what we can already do, what we cannot, and which of the two today’s method changes.

Lectures

Twenty-two lectures in five parts, all online now and all work in progress: expect them to change during the course. The Animations are one interactive page per lecture: each model from the lecture, run one step at a time in your browser, with the numbers shown at every step.

Part I — Tabular data and classical models

Lectures 1–6 · Chapters 1–8 · runs on CPU
  1. 01

    What machine learning is, and how we will work

    California housing Ch 1–2

    · 12:00–14:00 · Aula C

  2. 02

    The end-to-end project

    California housing Ch 2

    · 12:00–14:00 · Aula C

    Derivation · Least squares: the objective, its gradient, and convexity

  3. 03

    Honest evaluation, and classification metrics

    California housing, MNIST Ch 2–3

    · 12:00–14:00 · Aula Magna Geologia

    Derivation · The normal equation; the non-monotonicity of precision

  4. 04

    Training models

    Titanic Ch 4

    · 12:00–14:00 · Aula Magna Geologia

    Derivation · Gradient descent

  5. 05

    Ensembles and random forests

    CoverType Ch 6

    · 12:00–14:00 · Aula Magna Geologia

    Derivation · The variance of an average of correlated predictors

  6. 06

    Dimensionality reduction and unsupervised learning

    Olivetti faces Ch 7–8

    · 12:00–14:00 · Aula Magna Geologia

    Derivation · PCA via the SVD

Part II — Neural networks

Lectures 7–11 · Chapters 9–10, and the lecture notes · runs on CPU
  1. 07

    Neural networks

    Fashion-MNIST Ch 9

    · 12:00–14:00 · Aula Magna Geologia

    Derivation · What a layer computes

  2. 08

    PyTorch

    Fashion-MNIST Ch 10

    · 12:00–14:00 · Aula Magna Geologia

    Derivation · Backpropagation as reverse-mode automatic differentiation

  3. 09

    ML system design interview: harmful content detection

    A social platform's posts, in a mock interview Outside the book

    and · 12:00–14:00 · Aula Magna Geologia

  4. 10

    Explaining and auditing models

    Adult census income Outside the book

    · 12:00–14:00 · Aula 1, Via De Lollis

    Derivation · The Shapley value and its efficiency property

  5. 11

    Autoencoders and representation learning

    Fashion-MNIST Outside the book

    · 12:00–14:00 · Aula 1, Via De Lollis

Part III — Computer vision

Lectures 12–15 · Chapter 12 · runs on CPU
  1. 12

    Convolutional networks

    Flowers102 Ch 12

    · 12:00–14:00 · Aula 1, Via De Lollis

    Derivation · Weight sharing and equivariance

  2. 13

    Transfer learning

    Flowers102 Ch 12

    · 12:00–14:00 · Aula 1, Via De Lollis

  3. 14

    Detection and segmentation

    COCO Ch 12

    · 12:00–14:00 · Aula 1, Via De Lollis

    Derivation · IoU’s vanishing gradient; mAP

  4. 15

    ML system design interview: crop disease from a phone photo

    A farmers' cooperative, in a mock interview Outside the book

    · 12:00–14:00 · Aula 1, Via De Lollis

Part IV — Sequences and language

Lectures 16–18 · Chapters 13–15 · runs on CPU
  1. 16

    Recurrent networks

    Chicago transit ridership Ch 13

    · 12:00–14:00 · Aula 1, Via De Lollis

  2. 17

    Text

    IMDb Ch 14

    · 12:00–14:00 · Aula 1, Via De Lollis

    Derivation · Softmax, cross-entropy and logits

  3. 18

    Attention and transformers

    IMDb Ch 14–15

    · 12:00–14:00 · Aula 1, Via De Lollis

    Derivation · Scaled dot-product attention

Part V — Information retrieval and recommender systems

Lectures 19–22 · Outside the book · examinable
  1. 19

    Information retrieval: the lexical foundation

    SciFact (BEIR) Outside the book

    · 12:00–14:00 · Aula 1, Via De Lollis

    Derivation · Evaluating a ranking: MRR, AP, NDCG

  2. 20

    Information retrieval: dense retrieval

    SciFact (BEIR) Outside the book

    · 12:00–14:00 · Online

  3. 21

    Recommender systems: from ratings to factors

    MovieLens Outside the book

    · 12:00–14:00 · Aula 1, Via De Lollis

    Derivation · Matrix factorisation, and its relation to the SVD

  4. 22

    Recommender systems: neural, and evaluated honestly

    MovieLens Outside the book

    · 12:00–14:00 · Aula 1, Via De Lollis

Prerequisites

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.

A note on scope. Everything taught in this course comes from Chapters 1–10 and 12–15 of the textbook, or — for Lectures 9–11, 15 and 19–22 — from the lecture notes. The material on this page is the opposite: it is what the course assumes you already have, so the resources here necessarily point outside both. None of it is examinable in its own right.

Test yourself in ten minutes

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.

  1. $\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, the first line of the mathematics.

  2. 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.

  3. When is $\mathbf{X}^{\mathsf T}\mathbf{X}$ not invertible? Answer in terms of the columns of $\mathbf{X}$.

    The normal equation, where Lecture 2’s derivation leads; Lecture 3 names the condition, and Lecture 4 meets and repairs the case.

  4. $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.

  5. What does a 95% confidence interval mean — and what does it not mean?

    The housing project’s final test score.

  6. 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.

  7. 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.

  8. Read this traceback out loud and say which line of your code caused it, and why:
    ValueError: Input X contains NaN.

    The housing project, the first time preprocessing meets a missing value.

Could you do six or more? You are ready; skip the rest of this page. Fewer? Find the matching row below. Nothing here needs more than a few evenings, and none of it needs to be finished before Lecture 1 — the items are listed in the order the course first needs them.

Filling the gaps

Mathematics

What you needFirst neededIf 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.

Programming

What you needFirst neededIf 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.

What you also need on the day

What you explicitly do not need

Prior machine learning

Helpful, not assumed. The course starts from a problem and a dataset on the first day and builds everything from there.

Deep learning experience

Parts II–VI assume nothing beyond what Part I established. Neural networks arrive in Lecture 9, once the classical models have been covered properly.

Software engineering

No production systems, no deployment infrastructure, no build tooling. Notebooks throughout.

Fluent typing

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.

Calendar

Twenty-two lectures on Tuesdays and Wednesdays, from 6 October 2026 to 13 January 2027.

Days
Tuesday and Wednesday
Hours
12:00–14:00
Room
Aula 1, Via De Lollis (from 17 Nov 2026)
Every lecture in date order, and the days inside the term that carry none.
October 2026
01 What machine learning is, and how we will work
02 The end-to-end project
03 Honest evaluation, and classification metrics
04 Training models
05 Ensembles and random forests
06 Dimensionality reduction and unsupervised learning
07 Neural networks
08 PyTorch
November 2026
09 ML system design interview: harmful content detection
09 ML system design interview: harmful content detection · continued
— no lecture — cancelled
— no lecture — cancelled
10 Explaining and auditing models
11 Autoencoders and representation learning
12 Convolutional networks
13 Transfer learning
December 2026
14 Detection and segmentation
15 ML system design interview: crop disease from a phone photo
— Immacolata — the university is closed
16 Recurrent networks
17 Text
18 Attention and transformers
19 Information retrieval: the lexical foundation
— no lecture — cancelled
24 Dec – 4 Jan — Christmas break
January 2027
20 Information retrieval: dense retrieval · online
— Epiphany — the university is closed
21 Recommender systems: from ratings to factors
22 Recommender systems: neural, and evaluated honestly

All the material is online now, as a work in progress. Every lecture’s slides, notebook, notes and animations are already on this page. They are being revised during the course, so a lecture can change before it is taught and after.

The mathematics

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.

  1. Least squares: the objective, its gradient, and convexity · Lecture 2
  2. The normal equation; the non-monotonicity of precision · Lecture 3
  3. Gradient descent · Lecture 4
  4. The variance of an average of correlated predictors · Lecture 5
  5. PCA via the SVD · Lecture 6
  6. What a layer computes · Lecture 7
  7. Backpropagation as reverse-mode automatic differentiation · Lecture 8
  8. The Shapley value and its efficiency property · Lecture 10
  9. Weight sharing and equivariance · Lecture 12
  10. IoU’s vanishing gradient; mAP · Lecture 14
  11. Softmax, cross-entropy and logits · Lecture 17
  12. Scaled dot-product attention · Lecture 18
  13. Evaluating a ranking: MRR, AP, NDCG · Lecture 19
  14. Matrix factorisation, and its relation to the SVD · Lecture 21
The derivations are cross-referential and the order matters. Lecture 5 completes Lecture 2; Lecture 14 uses Lecture 3; Lecture 21 and Lecture 23 both use Lecture 8; Lecture 20 and Lecture 22 are the same architecture twice; Lecture 23 is evaluated with Lecture 19’s metrics.

Assessment

The written examination carries the mark. The oral is optional and short: it can raise that mark by at most three, or lower it by any amount.

Written examination

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.

Oral examination — optional

Seven to ten minutes. Three questions, on any topic from the course.

No notes, no computer. Open to anyone who passed the written.

How the mark is made The oral moves your written mark up by at most three marks, or down by any amount — below 18 included. A bad oral can fail an exam the written had passed, and the result is final. 28, 29 and 30 exist only through the oral, and lode is a separate decision, from 30.

Sitting it is your choice, made when you see your written mark — and binding once registered. Both are taken in the same session: a written pass does not carry forward.
Why it is built this way. A grade you can improve at no risk is one everybody attempts, which turns the oral into a queue rather than an examination. Making it a real decision — at most three marks up, and no limit on the way down — means the people who sit it are the people with something to show. Nothing about it is hidden: the questions are published, the arithmetic is published, and neither changes after you have decided.

Can a course this applied really have a written examination?

Yes — and this course is better suited to one than most applied courses, for a specific reason.

The competence being built here is not typing. It is judgement about whether a result can be trusted, and that judgement is exercised by reading: reading code you did not write, reading a metric, reading a curve. Reading is paper-native. A written examination tests it more directly than a lab does — at a keyboard a student can arrive at the right answer by running things until they look right, whereas on paper they have to actually know.

Three rules keep it honest.

  1. No question tests API recall. Asking for the arguments of train_test_split would test what a docstring is for. Syntax errors in handwritten code cost nothing; logic errors cost everything.
  2. No question is answerable by reciting a definition. Every one requires applying it to a stated situation.
  3. The paper states what it needs. There is no formula sheet, and none is required: any definition or standard result a question depends on is printed in the question itself. What you are expected to supply is the reasoning, never the recall.

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 written examination

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.

PartWhat it asksWeight
of the paper
Time
A · The derivations Derive, state, apply. The eighteen objects developed in the lectures — least squares, 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
Every exercise in the course, with its solution. Each deck ends with five questions in this style, answered on the following lecture’s deck. All 110 exercises are collected in one place: published once the course has run.

Three specimen questions

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.

Part A — derive, then apply

Two regressors each have variance $\sigma^2$ and are correlated with coefficient $\rho$.

  1. Show that the variance of their average is $\frac{\sigma^{2}(1+\rho)}{2}$.
  2. Bagging and a random forest differ in one respect. State it, and say which term in your expression it attacks.
  3. An ensemble of one hundred identical trees has $\rho = 1$. What does your expression predict, and is that the right answer?

Part B — choosing a method

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.

  1. Ordinary least squares, a decision tree, or a random forest — which do you fit first, and what specifically about the situation decides it?
  2. Name the one piece of evidence that would make you abandon that choice for one of the others.

They send you this program, and the number it printed.

best = None
for d in [2, 4, 6, 8, 12]:
    m = DecisionTreeRegressor(max_depth=d).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 = (d, s)

print(f"best depth={best[0]}, test RMSE={best[1]:,.0f}")
  1. This program never creates a validation set. Which object is doing that job?
  2. As an estimate of the model’s error on new data, the printed RMSE is (i) too optimistic, (ii) too pessimistic, or (iii) neither. Choose one and give the reason in a sentence.
  3. Rewrite it so the printed number is honest. Two statements is enough.

Every part has a determinate answer — a decision tree, because the regulator rules out the forest and a tree is indifferent to the near-duplicate columns that make $\mathbf{X}^{\mathsf T}\mathbf{X}$ ill-conditioned for least squares; 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.

Part C — reading results

Two teams report the following for the same dataset.

TeamTraining RMSE10-fold CV RMSE
A$0$68,574
B$68,233$68,282
  1. Name each pathology.
  2. Which model is more useful? Explain why that is not the same question as which is better fitted.
  3. One of these is helped by collecting more training data and the other is not. Which, and why?

The oral examination

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.

What happens

  • You decide after seeing your written mark. Until then there is nothing to opt into.
  • Three questions, on any topic from the course.
  • Seven to ten minutes, no notes, no computer.

What it is worth

  • Up by at most three marks. The only route to a mark above 27, and to lode.
  • Down by any amount, below 18 included. The same conversation can lower it, and can fail an exam the written had passed. This is not a formality.
  • Worth sitting from below the cap too — the movement is measured from your mark, wherever it is.

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.

Code you cannot explain earns nothing. Part B of the paper puts a cell in front of every candidate; the oral puts a question in front of the ones who choose it. Both apply to code an assistant wrote for you exactly as they apply to code you typed.

Note what is absent: there are no marks for a notebook that runs. Evidence earns marks.

Textbook and scope

Aurélien Géron, Hands-On Machine Learning with Scikit-Learn and PyTorch, O’Reilly, 2025 — Chapters 1–10 and 12–15, covering Lectures 1–8, 12–14 and 16–18. Chapter 11 is not part of the course.

Lectures 9–11 — the ML system design interview, explaining and auditing models, and autoencoders — Lecture 15 — a second design interview — and 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 eight 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 notesDataset
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
Scope discipline. The examinable surface is Chapters 1–10 and 12–15 plus the notes for Lectures 9–11, 15 and 19–22. Every section of every lecture is marked examinable, not examinable — engineering, or beyond the syllabus, for context, so you never have to guess.

Chapter coverage

ChapterLectures
1 · The machine learning landscape1
2 · End-to-end project1, 2
3 · Classification3
4 · Training models4
5 · Decision trees5
6 · Ensembles and random forests5
7 · Dimensionality reduction6
8 · Unsupervised learning6
9 · Introduction to artificial neural networks7
10 · Building networks with PyTorch8
11 · Training deep networks—
12 · Deep computer vision12, 13, 14
13 · Sequences16
14 · NLP with RNNs and attention17, 18
15 · Transformers18, 23, 24
16 · Vision and multimodal transformers23, 24
Lecture notes · Autoencoders11
Lecture notes · Information retrieval19, 20
Lecture notes · Recommender systems21, 22

Practicalities