Machine Learning · Insper

The ML Landscape

Fundamental approach

The kinds of learning, the project loop, and what it means for a model to generalize

The path of this part

  1. Kinds of learningsupervised, unsupervised, reinforcement: by the feedback
  2. The project loopframe, get data, prepare, train, evaluate, deploy: a loop
  3. Generalizationtraining and new data; underfitting and overfitting
Each stage answers one question: which kind of learning, by its feedback? → which steps does a real project take? → what makes a model good on data it has never seen?
Stage 1 · which kind of learning, by its feedback?

Learning paradigms: by the feedback

Machine learning (ML) problems are classified by the kind of feedback the learner gets.

Predict. Three situations: (a) past e-mails, each marked spam or not; (b) a pile of customer records, no marks at all; (c) a program that plays a game and only learns at the end whether it won. What feedback does each one have?

Three paradigms

Supervised learning: inputs and the answers

The data contains inputs \(x\) and the desired outputs \(y\) (labels). Goal: learn a function \(f\) with \(f(x) \approx y\) on new data.

regression

\(y\) is continuous: house prices, energy demand, a patient's length of stay

classification

\(y\) is categorical: spam or not, benign or malignant tumor, which digit is in the image

The type of \(y\) names the task, not the algorithm: a number is regression, a category is classification.

Unsupervised learning: only the inputs

No labels. The goal is to discover structure.

clustering

group similar observations, e.g. customer segments

dimensionality reduction

compress many features into a few informative ones: PCA (principal component analysis), t-SNE, UMAP

topic modeling

discover themes in a collection of documents (BERTopic)

Reinforcement learning, and the mixtures

  • An agent acts in an environment, receives rewards and learns a policy that maximizes long-term reward: game-playing systems (AlphaGo), robotic control.
  • Out of scope for this course, but you should recognize it on the map.

semi-supervised

few labels, many unlabeled examples

self-supervised

labels manufactured from the data itself: how foundation models are pre-trained

weak supervision

noisy, programmatic labels

Stage 2 · which steps does a real project take?

The ML workflow

A model is a small part of a larger, iterative process. The course is organized around this loop.

Two practical truths about the loop

most of the work is in steps 2–3

practitioners routinely report spending most of their time understanding and preparing data, not fitting models

the loop never ends

deployed models decay as the world changes (drift); monitoring and retraining are part of the job

Step 1, frame the problem, looks the easiest and is where a project is most often doomed: the advanced approach gives it its own section.
Stage 3 · what makes a model good on data it has never seen?

Generalization: the central problem

Predict. A model gets every training example right: it has memorized them. Is it a good model?

It can still be useless. What matters is performance on data it has never seen.

underfitting

too simple to capture the pattern: poor even on the training data

overfitting

captures noise as if it were signal: excellent on training, poor on new data

Three models, by eye

15 training points (orange) around a curve plus noise; 1,000 new points (blue) the models never see. Error: MSE (mean squared error), the average squared vertical distance. Predict: rank degrees 1, 3, 12 by training error. Same order on new points?

Degree 1 underfits (training 0.208, new 0.435), degree 3 balances (0.036, 0.119), degree 12 overfits (0.004, 92.010)
Training error: 0.208 → 0.036 → 0.004, always falling. Error on new points: 0.435 → 0.119 → 92.010. The two rankings disagree, and only the second describes the model once deployed.

Simulator: underfitting and overfitting

Predict. As the degree goes from 1 to 15, what happens to the training error? And to the test error? Then press more data.

The golden rule

  • In the lab and the simulator, "new points" come from a generator we wrote: we can draw the future at will.
  • A real project has no such generator. The only stand-in for the future is data you set aside and never train on.
  • Train/test splits, cross-validation, regularization, the bias–variance trade-off: all exist to manage this tension.
The golden rule. Never evaluate a model on data it was trained on. Test data must simulate the future: unseen, untouched, used once.

Summary

  1. Paradigms by feedback: supervised (labels), unsupervised (structure), reinforcement (rewards).
  2. In supervised learning the type of \(y\) names the task: regression or classification.
  3. The workflow is a loop, and most of the work is in the data.
  4. Read two errors, never one: both high is underfitting; training low and new-data high is overfitting.
  5. Only data the model never saw can judge it: never evaluate on the training data.
what you seewhat is happening
both errors high and closeunderfitting: too simple
training tiny, new data much largeroverfitting: it memorized the noise
a deployed model slowly getting worsedrift: the world changed
Fundamental lab · about 30 min, in pairs

The shape of the error, steps 1 to 4

  • A world you control: 15 training points around a curve, and 1,000 new points from the same process.
  • Polynomials of growing degree, then a model that only memorizes: watch the training error and the error on new points.
  • The code is on the lesson page: paste each block into a blank Colab notebook, in order. Nothing to install.
  • At every step, answer the Predict before running.
  • Simulations: more data (step 3) and nothing to learn (step 4).

Pace: steps 1 and 2 in 8 min; step 3 and the first simulation in 10 min; step 4 and the second in 12 min.