How machines learn from data, built from plain Python on tiny datasets so you can watch every number change. No libraries, no black boxes.
Machine Learning · beginner · 13 lessons · 2 h 25 min · free
What you'll learn
Watch a model learn a hidden rule from data, one correction at a time
Understand the loss, the gradient and the learning rate by seeing their numbers
Classify with neighbours, probabilities and decision trees, and find groups with k-means
Build a tiny neural network, train it with backpropagation, and see why test data keeps models honest
Before you start
Basic Python: lists, loops and functions
Lessons
Data as Numbers
Turning things into lists of numbers, and comparing them.
Vectors and the Dot Product: Describe a film and a viewer as lists of numbers, then multiply and add to measure how well they match: the dot product behind recommendations and neural networks.
Putting Features on the Same Scale: Grams and a 1-to-10 sweetness score live on very different scales. See how that makes one feature drown out the other, and how scaling to 0-1 fixes it.
Learning from Data
How a model improves by measuring its mistakes and correcting them.
How a Model Learns: Gradient Descent: Train a tiny model on four data points and watch it discover a hidden rule by predicting, measuring its error and correcting itself, one line at a time.
Classifying
Deciding which kind of thing something new is, from examples.
k-Nearest Neighbours: Judge by the Company: Classify a new fruit as an apple or a lemon by measuring how far it is from every known fruit and letting its nearest neighbours vote.
Logistic Regression: From Score to Chance: Turn a straight line into a probability with the sigmoid curve, predict each student's chance of passing, then take one learning step.
Decision Trees: Finding the Best Question: A decision tree learns by asking yes/no questions. Try four questions of the form "is the size above t?" and measure which one separates apples from lemons best, with Gini impurity.
Finding Groups
Finding structure in data when nobody gives the answers.
k-Means: Finding Groups Without Answers: No labels this time: find two groups of shoppers by repeating two moves. Everyone joins the nearest centre, then each centre moves to the middle of its group.
Neural Networks
From one artificial neuron to networks of them.
One Neuron Learns: The Perceptron: Watch a single artificial neuron learn the AND rule from four examples: weighted sum, fire or not, measure the mistake, nudge the weights.
A Tiny Network Solves XOR: One neuron can draw only one straight line, so it cannot do XOR. Add two hidden neurons, each drawing its own line, and an output neuron that combines them.
Deep Learning
How deep networks learn their weights, bend their outputs, and see images.
Backpropagation: Sharing Out the Blame: How does a network with a hidden layer learn? Work out how much each weight is to blame for the error, starting at the output and passing it back, one link at a time.
Activation Functions: Bending the Line: Step, sigmoid, tanh and ReLU: four ways a neuron can bend its output. Without a bend, any number of layers adds up to one straight line.
Convolution: How Networks See Edges: Slide a 3 × 3 filter over a tiny image and add up what it covers. Where dark meets bright, the numbers jump: the filter has found an edge.
Testing Models
Checking that a model works on data it has never seen.
Train, Test, and Overfitting: A model that memorises its training data scores perfectly on it and badly on anything new. Hold some data back, and test on that.
Related courses
AI Agents and RAG: Build Them Step by Step: How retrieval-augmented generation and AI agents really work, built from small Python programs: embeddings, chunking, vector search, grounded answers, the agent loop, memory, planning, multi-agent routing, guardrails and MCP. Watch every score, tool call and decision as it happens. (16 lessons, 1 h 50 min)
How AI Language Models Work: Tokens, embeddings, attention, training, RAG and agents, each built in a few lines of plain Python so you can watch every number. No libraries, no black boxes. (20 lessons, 2 h 51 min)
AI Beyond Language Models: Search, game playing, learning from rewards, image generation, recommendations, forecasting and sound, each in a few lines of plain Python you can step through. (7 lessons, 58 min)