How a model actually learns
The guess, check, adjust, repeat loop that every ML model runs, shown first with a guessing game and then with real numbers.
A guessing game with no math at all
Play this game with me. I'm thinking of a number between 0 and 100. You guess 50. I say "lower." You guess 25. I say "higher." You guess 37. I say "lower." You guess 31...
Notice what you're doing without thinking about it: you make a guess, you get told whether it was too high or too low, and you adjust your next guess based on that feedback. You never see the answer directly — you only ever see "warmer" or "colder" signals, and you use those to close in on it.
This is, almost exactly, how a machine learning model trains. Swap "the number I'm thinking of" for "the correct output," and swap "your guess" for "the model's prediction," and you have the entire training loop.
The four-step loop, precisely
Every supervised learning model, no matter how simple or how enormous, trains using this exact loop:
- Predict. The model looks at an input and produces a guess, using its current parameters (its current knobs).
- Measure the error. Compare the guess to the actual correct answer. How wrong was it? This "how wrong" number is called the loss.
- Figure out which direction reduces the error. For each knob, work out: if I turned this knob up slightly, would the error get bigger or smaller?
- Adjust. Nudge every knob a small step in the direction that reduces the error.
Then repeat this thousands or millions of times, across all the training examples, and the knobs gradually settle into values that make good predictions.
Turning this into an example you can trace by hand
Suppose you're trying to predict a house's price using only its size, with a formula this simple:
Here is the one knob — a single number we need the model to figure out. Say the true relationship in the world is roughly 100{,}000$.
Step 1 — Predict. We start with a random guess for the knob, say . For a 50 m² house, the model predicts:
Step 2 — Measure the error. The real sale price was . The model is off by:
That's a huge miss. is clearly too small.
Step 3 — Which direction reduces the error? If we increase , the prediction goes up, and since our prediction is too low, increasing moves us closer to correct. So the direction is: increase .
Step 4 — Adjust. We nudge upward by some amount — say to — and go back to step 1 with the next house in our dataset.
Do this across thousands of houses, thousands of times, gradually shrinking how big each nudge is as the guesses get closer, and settles in right around — the model has "learned" the price-per-square-meter relationship, purely from examples, without anyone typing in the number 2,000.
Naming the pieces, now that you've felt them
Now that the mechanics make sense, here's the vocabulary you'll see everywhere from here on:
- Parameters — the knobs. In the house example, is a parameter. Real models have anywhere from a handful to trillions of them.
- Loss function — the precise formula for "how wrong was the guess." We'll define this properly (with actual math) in the training module — for now, just think of it as a number that's big when the model is wrong and shrinks toward zero as it gets better.
- Gradient descent — the formal name for "figure out which direction reduces the error, then nudge in that direction." It's called gradient because that direction is computed using calculus (the math foundations module covers exactly how), and descent because we're walking downhill on the error, trying to reach the lowest point.
- Learning rate — how big each nudge is. Too big, and you overshoot the answer and bounce around. Too small, and training takes forever. Getting this right is one of the most common practical struggles in ML.
- Training — the whole process of running this loop across all your examples until the loss stops shrinking.
Why this loop is worth memorizing
Every model in this course — linear regression, logistic regression, decision trees, and full neural networks — is a variation on this exact loop. What changes between them is what the knobs are, how predictions are computed from the knobs, and how the loss is defined. The loop itself — predict, measure, find the direction, adjust, repeat — never changes. Once it's solid, every later lesson is really just "here's a new shape for the knobs, and here's a new way to compute the prediction."
The next module builds the actual math toolkit — vectors, slopes, and probability — that lets us write "figure out which direction reduces the error" as a precise formula instead of an intuition.