Mirage Academy · Machine learning

Machine learning course: train, validate and judge a model yourself

You see machine learning results at work, and you cannot yet tell whether a model learned anything real. This course shows how a model learns from data, how to train one, and how to check its score instead of trusting it. It starts from the beginning and ends with a classifier you evaluate yourself.

Open the machine learning courseSee the computer vision course

The course

Eight chapters take you from learning from data to a classifier you judge yourself

The course is for software engineers and technical product people who build AI features. It is a beginner course, and it is taught in English. Watch the intro, then climb the steps.

Still from the intro video for the course Applied Machine Learning & Deep Learning Foundations
Intro video, 1 min 16 s. Transcript below.
Read the transcript

You see machine learning results at work, but you cannot yet tell whether a model learned anything real. This course shows how models learn from data, and how to check one yourself. Today a model may feel like a black box. First, you will name the kind of learning a task needs. Second, you will frame it as regression or classification. Third, you will judge a score with a validation set instead of trusting it. At the core sits one loop. The model makes a prediction. A loss function measures the error. Gradient descent adjusts the weights. A validation set checks that the model still generalizes. Then you build on that loop with neural networks, embeddings and transfer learning. In the capstone, you train and evaluate a classifier from start to finish. If you want to train, validate and judge a model yourself, start with chapter one, on learning from data.

Open the course: Applied Machine Learning & Deep Learning Foundations

The loop at the core of the course

  1. 1The model predicts
  2. 2A loss measures the error
  3. 3Gradient descent adjusts the weights
  4. 4A validation set checks the result

The steps

  1. Chapter 1Learning from data: supervised and unsupervised
  2. Chapter 2Regression and classification
  3. Chapter 3Loss functions and gradient descent
  4. Chapter 4Neural networks
  5. Chapter 5Training, validation and overfitting
  6. Chapter 6Embeddings
  7. Chapter 7Transfer learning
  8. Chapter 8Capstone: train and evaluate a classifier
The intro video and the four steps of the learning loop on the left, the eight chapters as a staircase on the right, the top step in amber.

Chapter 1

Learn from labels, or let the data show its own groups

This chapter covers supervised and unsupervised learning, shown with a threshold rule and with k-means, then features, data quality and baselines.

Example points, invented for this page

Supervised: the points have labels

Class AClass Bthreshold

2 of 12 points on the wrong side of the line

An example threshold rule on one feature. The points on the wrong side of the line are counted.

Unsupervised: no labels

cluster center

An example of two groups, each with a center at the mean of its points.

  1. 01

    What it means to learn from data

    Lesson 1: what it means to learn from data.

  2. 02

    Supervised learning and a threshold rule

    Lesson 2: supervised learning, shown with a threshold rule.

  3. 03

    Unsupervised learning with k-means

    Lesson 3: unsupervised learning, shown with k-means.

  4. 04

    Features and data quality

    Lesson 4: features, and the quality of the data.

  5. 05

    Baselines, honest scores and mistakes to avoid

    Lesson 5: baselines, honest scores and mistakes to avoid.

Two scatter plots of example points: labeled points with a dotted threshold on the left, unlabeled points with two cluster centers on the right.

New to AI? Start with AI for beginners →

Chapter 2

Fitting a line, logistic regression and trees

This chapter covers fitting a line, measuring regression error, logistic regression, choosing a threshold, and trees and nearest neighbors.

Example data, invented for this page. The curve is an example: a common way to picture logistic regression

Regression: how far off is the line?

Mean squared error: 3.8

Each segment is the error of one point. The mean squared error is the average of their squares.

Classification: a curve and a threshold

threshold 0.5

sample score 1.2 gives 0.77: above the threshold: class yes

Example: a common way to picture logistic regression, with a threshold.

  1. 01

    Fitting a line

    Lesson 1: fitting a line.

  2. 02

    Measuring regression error

    Lesson 2: measuring regression error.

  3. 03

    Logistic regression

    Lesson 3: logistic regression.

  4. 04

    Choosing a threshold

    Lesson 4: choosing a threshold.

  5. 05

    Trees and nearest neighbors

    Lesson 5: trees and nearest neighbors.

A fitted line with the error of each point drawn as a segment, beside an example S shaped curve with a threshold and one sample point.

Chapter 3

Gradient descent with four learning rates, step by step

This chapter covers loss as a score, the gradient, learning rate, batch, mini-batch and stochastic steps, and reading a training run. Pick a learning rate in the example and take steps.

Walk down the loss, one step at a time

The data is an example for this page: four points that a weight of 2 fits exactly.

Learning rate

best weight 2

Steps taken
0
Weight
0
Loss
30

In this example each step lands closer to the best weight.

Learning rate 0.05, 0 steps: weight 0, loss 30. In this example each step lands closer to the best weight.

The rule: one step sets the weight to the weight minus the learning rate times the gradient. For this example the distance to the best weight is multiplied by 1 minus 15 times the learning rate at each step. When that factor sits between minus 1 and 1 the run settles, and it grows when the rate is above about 0.133.

  1. 01

    Loss as a score

    Lesson 1: loss as a score.

  2. 02

    The gradient

    Lesson 2: the gradient.

  3. 03

    Learning rate

    Lesson 3: learning rate.

  4. 04

    Batch, mini-batch, stochastic

    Lesson 4: batch, mini-batch and stochastic.

  5. 05

    Reading a training run

    Lesson 5: reading a training run.

An interactive run of gradient descent on one weight: pick a learning rate, take steps, and watch the weight and the loss.

Chapter 4

Neural networks: layers, a forward pass and a parameter count

This chapter covers the neuron, layers and the forward pass, counting parameters, backpropagation in one step and why hidden layers.

An example network, invented for this page

Inputs: 3Hidden layer 1: 4Hidden layer 2: 4Output: 1

Weights
32
Biases
9
Parameters
41

The rule: a layer with n inputs and m outputs has n times m weights and m biases. The network's parameters are the sum over its layers.

  1. 01

    The neuron

    Lesson 1: the neuron.

  2. 02

    Layers and forward pass

    Lesson 2: layers and the forward pass.

  3. 03

    Counting parameters

    Lesson 3: counting parameters.

  4. 04

    Backpropagation in one step

    Lesson 4: backpropagation in one step.

  5. 05

    Why hidden layers

    Lesson 5: why hidden layers.

A network of four layers drawn as columns of nodes with each node joined to the next column, with its weights, biases and total counted below.

Chapter 5

Three sets and cross-validation

This chapter covers three sets, overfitting, cross-validation, regularization and early stopping, and leaks in the pipeline.

Example split, not from the course. Row counts invented for this page: 100

  • Train60
  • Validation20
  • Test20
  1. Fold 1validatetraintraintraintrain
  2. Fold 2trainvalidatetraintraintrain
  3. Fold 3traintrainvalidatetraintrain
  4. Fold 4traintraintrainvalidatetrain
  5. Fold 5traintraintraintrainvalidate

validatetrain5 x 16 = 80

Example split, not from the course: here the test rows stay out of the folds.

The rule of this example picture: the rows outside the test set are cut into k folds, each fold is the validation fold once, and the other folds train.

  1. 01

    Three sets

    Lesson 1: three sets.

  2. 02

    Overfitting

    Lesson 2: overfitting.

  3. 03

    Cross-validation

    Lesson 3: cross-validation.

  4. 04

    Regularization and early stopping

    Lesson 4: regularization and early stopping.

  5. 05

    Leaks in the pipeline

    Lesson 5: leaks in the pipeline.

A bar of one hundred example rows cut into three sets, and a grid of five folds in which each fold takes one turn as the validation fold.

Chapter 6

Embeddings: vectors, similarity and nearest neighbors

This chapter covers going from ids to vectors, similarity, nearest neighbors, how embeddings are learned, and limits.

Two number vectors, invented for this page

Cosine to the query (cat)

  1. kitten0.99 · nearest
  2. dog0.98
  3. truck0.51

The rule: the cosine of two vectors is their dot product divided by the product of their lengths. It is 1 when they point the same way and 0 when they are at a right angle.

  1. 01

    From ids to vectors

    Lesson 1: from ids to vectors.

  2. 02

    Similarity

    Lesson 2: similarity.

  3. 03

    Nearest neighbors

    Lesson 3: nearest neighbors.

  4. 04

    How embeddings are learned

    Lesson 4: how embeddings are learned.

  5. 05

    Limits

    Lesson 5: limits.

Four example words drawn as arrows from one point, the query word in cyan, with the cosine of each other word to the query listed beside them.

Chapter 7

Transfer learning: freeze, train a head, unfreeze

This chapter covers reusing a pretrained model, freezing it and training a head, unfreezing, learning rates and domain shift.

A picture of the idea, not a real model

  1. Freeze and train a headLesson 2 of this chapter.Block 1: frozenBlock 2: frozenBlock 3: frozenBlock 4: frozenBlock 5: frozenNew head
  2. UnfreezingLesson 3 of this chapter.Block 1: frozenBlock 2: frozenBlock 3: frozenBlock 4: trainedBlock 5: trainedNew head
  3. Learning ratesLesson 4 of this chapter.Block 1: frozenBlock 2: trainedBlock 3: trainedBlock 4: trainedBlock 5: trainedNew head

trainedfrozen (dashed)

The last lesson of this chapter is about domain shift.

  1. 01

    Reusing a pretrained model

    Lesson 1: reusing a pretrained model.

  2. 02

    Freeze and train a head

    Lesson 2: freeze and train a head.

  3. 03

    Unfreezing

    Lesson 3: unfreezing.

  4. 04

    Learning rates

    Lesson 4: learning rates.

  5. 05

    Domain shift

    Lesson 5: domain shift.

Three rows of the same stack of five pretrained blocks and a new head: each row shows a stage named after a lesson of the chapter.

Images next: the computer vision course →

Chapter 8

The capstone: train and evaluate a classifier

You frame the task, work one step by hand, train and watch, evaluate honestly and write the report.

The capstone in five steps

  1. 01Frame the task
  2. 02One step by hand
  3. 03Train and watch
  4. 04Evaluate honestly
  5. 05The report

One step by hand

Same example data as the island above.

Before
Weight 0, Loss 30
Gradient
-30
Weight
0 - 0.05 x (-30) = 1.5
After one step
Weight 1.5, Loss 1.875
The five lessons of the capstone chapter as five stations, with one worked step of gradient descent beside the second one.

The same craft on match data: the sports analytics course →

How you learn

A coach that questions how you explain a model, and a certificate at the end

Each lesson is paired with an AI coach in the Academy, and you speak to it by voice.

AI coachAIby voice
  1. It asks you to explain

    After a lesson on loss or overfitting, the coach asks follow-up questions to test whether you understood, as the app describes it.

  2. Your notes carry over

    Whatever notes you save are where your next session starts, according to the app.

  3. A certificate at the end

    Finishing this course earns a certificate, or a confirmation of participation, depending on how you went through it. It is a PDF with a verification code that anyone can check on a public page. Mirage issues it itself; it is not a state-recognized qualification.

Three nodes on one thread: the coach questions your reasoning about a model, your notes carry over, and the certificate closes the course.

All rules for the certificate →

Questions about the machine learning course

  • Who is the machine learning course for?

    Software engineers and technical product people who build AI features, at beginner level.

  • What is gradient descent?

    Chapter 3 covers loss as a score, the gradient, learning rate, batch, mini-batch and stochastic steps, and reading a training run. The interactive example on this page runs one example with four learning rates.

  • Does the course cover neural networks?

    Yes. Chapter 4 covers the neuron, layers and the forward pass, counting parameters, backpropagation in one step and why hidden layers.

  • How do I judge a model's score?

    The course pitch is to judge a score with a validation set instead of trusting it. Chapter 5 covers three sets, overfitting, cross-validation, regularization and early stopping, and leaks in the pipeline.

  • What are embeddings?

    Chapter 6 covers going from ids to vectors, similarity, nearest neighbors, how embeddings are learned, and limits. The picture on this page compares example vectors by cosine.

  • What is the final project?

    The capstone: you train and evaluate a classifier. You frame the task, work one step by hand, train and watch the run, evaluate honestly and write the report.

  • Do I get a certificate for the machine learning course?

    Yes, or a confirmation of participation, depending on how you went through the course. The PDF has a verification code that a public page can confirm, and the page about certificates states it is not a state-recognized qualification.

  • How does the coach help me learn machine learning?

    You speak with it by voice. The app says it asks follow-up questions and tests what you understood, for example why a model overfits.