Course · 33 of 38 lessons ready · 385 min
Machine learning from zero
Short lessons that take you from “what is a model?” to how a language model picks the next word. In every lesson you change something in a live lab on real data, watch the model react and check yourself with three questions. No code needed.
Lessons
Seven modules: from the whole journey on one dataset to a model out in the world. Lessons without a link are still being written.
Module 0 · The whole game
What does the whole journey from a question to an evaluation look like?
Module 1 · How a model learns from examples
Where does a model get its rule, and what do you compare it with?
- 1.1What is machine learning?Machine learning lets a program find its rule in examples instead of having a person write it. The lesson shows the difference on real breast tumour data.Lesson 1.1
- 1.2Data, features, labels and splitsA dataset is a table of examples, features and labels. Why the test set must stay hidden, and why its size decides how much a score can be trusted.Lesson 1.2
- 1.3Baselines: what do you compare your model with?Before praising a model, compute the score without learning: the top class or the mean. When the sick are rare, “always healthy” scores high and finds no one.Lesson 1.3
- 1.4Nearest neighbours: the simplest modelkNN learns no rule: a new case gets the label held by most of its k nearest examples. The number k shapes the borders, and the units decide who counts as near.Lesson 1.4
- 1.5Linear regression: fitting a lineLinear regression draws the straight line that misses the data least. On diabetes data, mean squared error decides which line is best.Lesson 1.5
- 1.6Gradient descent: learning by small stepsGradient descent finds good parameters by repeatedly stepping downhill on the error. The learning rate decides between progress and explosion.Lesson 1.6
Module 2 · Classification and evaluation
When is a result good, and for whom?
- 2.1Classification: drawing a boundaryA classifier turns measurements into a category. Logistic regression gives a probability and a boundary; the lesson shows both on two penguin species.Lesson 2.1
- 2.2Evaluating a classifier: beyond accuracyAccuracy hides which mistakes a model makes. The confusion matrix, precision and recall reveal the trade-off a threshold creates on tumour data.Lesson 2.2
- 2.3Thresholds, ROC and PR: every threshold at onceROC and precision–recall curves show every threshold at once. When a class is rare, ROC AUC hardly moves while AP falls, because false alarms eat precision.Lesson 2.3
- 2.4Calibration: does 0.8 mean 80%?A model can sort well yet give wrong percentages. Naive Bayes declares 98% confidence and is right 88% of the time. Temperature fixes this, decisions stay.Lesson 2.4
- 2.5Imbalanced classesWhen one class is rare, accuracy hides the losses and the model learns to say “the common class”. Recall, balanced accuracy and class weights show and patch it.Lesson 2.5
- 2.6A metric and threshold for the cost of mistakesPick the threshold by the price of mistakes, not by habit. When a miss costs 10 times more than a false alarm, the cheapest threshold lies near 0.09, not 0.5.Lesson 2.6
- Project A: screeningYour first portfolio project: pick a model and a threshold for screening when a miss costs 10 false alarms, then check your choice on a hidden test.
Module 3 · Generalisation
Will the model work tomorrow, on new data?
- 3.1Overfitting: when a model memorisesA flexible model can fit its training data perfectly and still fail on new data. As a polynomial's degree rises, training and test error part ways.Lesson 3.1
- 3.2Validation and cross-validationChoosing settings with the test set spoils it. Cross-validation tests a model on every part of the data in turn and shows how stable its score really is.Lesson 3.2
- 3.3Learning curves: more data or a better model?Learning curves show the training and validation score as the data grow. Their shape tells you whether to collect more data or switch to a richer model.Lesson 3.3
- 3.4Regularisation: ridge and lassoA penalty on large weights calms a model. Ridge shrinks every weight, lasso zeroes them one by one: with 3 of 10 features test R² falls from 0.470 to 0.386.Lesson 3.4
- 3.5Tuning hyperparameters without cheatingThe best of 9 tree settings scores 93.7% in cross-validation and 88.3% on new biopsies. Picking the winner inflates its score, just as picking the seed does.Lesson 3.5
- 3.6Early stoppingA network trained too long memorises wrong labels. With 20% random labels, 100 epochs instead of early stopping cut test accuracy from 86.1% to 76.3%.Lesson 3.6
Module 4 · Data in practice
What breaks models before you even start?
- 4.1Exploration: look before you modelFour data sets with the same mean, correlation 0.82 and line look nothing alike. Draw the data before you trust the numbers and before you build a model.Lesson 4.1
- 4.2Missing dataDrop rows with a gap and 333 of 344 penguins remain. When the heaviest lack BMI, the mean in the gaps weakens the link with disease; the gap itself says a lot.Lesson 4.2
- 4.3Categories and scalingkNN on wines scores 0.695 without scaling and 0.963 after standardising. Islands written as 0, 1, 2 fake an order: one-hot lifts R² from 0.469 to 0.546.Lesson 4.3
- 4.4Feature engineeringCultivar 2 sits mid-axis and no threshold cuts it out. A new column x² gives 77.4% instead of 60.4%; 200 noise columns drag kNN from 98.1% to 77.4%.Lesson 4.4
- 4.5Data leakageLeakage is information from the test or the future that reaches a model's training. On pure noise it fakes 82% in validation. Learn 8 types and find them.Lesson 4.5
- 4.6Pipelines: from a table to a predictionThe scaler is part of the model and learns on the training only. Fitted on the test itself, it gives 44.1% instead of 99.0% for penguins arriving one by one.Lesson 4.6
- Project B: a clean tableSecond portfolio project: from a raw penguin table (gaps, categories) build a pipeline that does not leak, then find the leak in three other people’s pipelines.
Module 5 · Models that win on tables
Which model, when and why?
- 5.1Decision trees: twenty questions with dataA decision tree classifies by asking yes-or-no questions, each chosen to split the data as cleanly as possible. The example: who survived the Titanic.Lesson 5.1
- 5.2Ensembles: why many trees beat oneAn ensemble combines many imperfect models whose errors partly cancel out. That is why a random forest becomes more accurate and stable with more trees.Lesson 5.2
- 5.3Gradient boosting: trees that fix each other’s errorsEvery tree fixes the errors of the ones before it. After 200 trees at step 1 training falls to 2287, while the test rises to 5944, worse than a line (4095).Lesson 5.3
- 5.4Naive Bayes: a false assumption, good decisionsNaive Bayes assumes independent features. On iris petals (r = 0.80) it gets 93.3% right, but on 171 validation tumours it declares 98.3% at 88.3% accuracy.Lesson 5.4
- 5.5Support vector machines and kernelsAn SVM looks for the widest band between the classes. As C grows from 0.01 to 100 the band shrinks from 3.9 to 0.15 cm and the test barely moves.Lesson 5.5
- 5.6Which model when?Five models, five datasets, 20 splits. No model is at the top everywhere, and a gap of 0.3 points can be a draw: 10 splits against 7.Lesson 5.6
- Project C: a mini competition in the browser
Module 6 · No teacher, interpretation, the model in the world
What does a model do without labels, what does it look at, and what happens after deployment?
- k-means: groups without labels
- PCA: fewer dimensions, the same content
- Anomaly detection
- What does the model look at? Feature importance
- After deployment: drift and fairness
- Project D: explain a model
Bridge (optional): Neural networks and language models
What next: a step towards networks and large language models.
The whole course: Neural networks from the inside (PL) · 12 lessons
- 7.1Neural networks: many simple units togetherA neural network stacks simple units that each draw one line and bend it. More hidden units let the decision regions curve around iris flowers.Lesson 7.1
- 7.2From neural networks to large language modelsA large language model is trained to guess the next token. The lesson builds the idea from a word-counting model and shows how temperature changes its output.Lesson 7.2
This course in other languages
Polski · Kurs uczenia maszynowego od zeraEspañol · Machine learning desde ceroDeutsch · Machine Learning von Grund aufFrançais · Le machine learning en partant de zéroPortuguês · Machine learning do zero