For decades, software meant writing rules: if this, then that. Machine learning flips that on its head. Instead of writing the rules, you show the computer thousands of examples and let it figure out the rules itself. This course explains how that works — and, just as important, when it goes wrong.
- Understand why "learning from examples" beats "writing rules" for some problems
- Tell apart the three families: supervised, unsupervised, and reinforcement learning
- Recognise overfitting — the single most common way ML goes wrong
- Judge whether a model is actually good, using the right measure for the job
Rules vs. learning — when examples win
Imagine writing software to spot spam email. The rules approach: if it contains "free money", mark as spam. Spammers write "fr3e m0ney" and you are back to square one. You add another rule. They adapt again. You lose.
The machine learning approach: show the computer a million emails already labelled "spam" or "not spam," and let it learn the patterns that separate them — patterns far too subtle and numerous to write by hand. When spammers adapt, you feed in new examples and the model relearns.
- Traditional software follows hand-written rules; ML learns rules from examples
- ML shines when patterns are too complex or change too fast to code by hand
- Not every problem needs ML — simple, stable logic is better as plain rules
The three families of learning
Almost all machine learning falls into three families, and the difference comes down to what the computer is shown.
| Family | What it gets | What it learns | Everyday example |
|---|---|---|---|
| Supervised | Examples with the right answers | To predict the answer for new cases | Spam filter (emails labelled spam / not) |
| Unsupervised | Examples with no answers | To find structure and groupings | Grouping customers into types nobody pre-defined |
| Reinforcement | A goal and rewards for good moves | To act well through trial and error | A program learning to play chess by winning and losing |
Supervised learning is by far the most common. You give it labelled examples — photos tagged "dog" or "cat," houses with their sale prices — and it learns to predict the label. Predicting a category (dog/cat) is called classification; predicting a number (a price) is called regression.
Unsupervised learning gets no labels. You hand it your customers and say "find natural groups." It might discover that you actually have three kinds of customer — something nobody told it to look for. This is how "customers like you also bought…" begins.
Reinforcement learning learns by doing. It tries an action, gets a reward or penalty, and gradually learns a strategy that earns the most reward. It is how programs master games — and, notably, part of how modern chatbots are tuned to be helpful (more on that later in the track).
- Supervised: learn from examples with answers (most common — classification & regression)
- Unsupervised: find hidden structure in data with no answers (grouping, patterns)
- Reinforcement: learn good behaviour through rewards and trial and error
- You want to predict tomorrow's temperature from past weather. Which family, and is it classification or regression?
- You have a pile of news articles and want to auto-group them by topic, with no pre-set topics. Which family?
How a model fits the data
At heart, training a model means finding the line (or curve, or boundary) that best fits your examples. Picture house prices: bigger houses cost more. Plot size against price, and the model draws the line that best runs through the dots. Now, given a new house's size, it reads the price off the line.
price
| •
| • /
| • / <- the line the model learned
| • /
| • /
| • /
|________/_______________ size
^ new house: find its size, read the price off the line
For classification, instead of a line through the dots, the model draws a line between the groups — a boundary with "dogs" on one side and "cats" on the other. Fancier models draw wiggly boundaries that separate complicated groups. But the idea never changes: fit the examples, then use the fit to judge new cases.
How does it find the best line? Exactly the "walking downhill" idea from the maths course — it starts with a bad line and nudges it, step by step, until the error is as small as it can be.
- Training = finding the line, curve, or boundary that best fits the examples
- Regression fits a line through the data; classification draws a boundary between groups
- The "best fit" is found by gradient descent — stepping downhill to less error
Overfitting — the trap that catches everyone
Here is the most important warning in all of machine learning. A model can do too well on the examples it studied — by memorising them instead of learning the real pattern. This is called overfitting, and it is the number one reason AI projects disappoint in the real world.
An analogy: a student who memorises the exact answers to last year's exam will ace a re-run of that exam — and fail this year's, because they learned the answers, not the subject. An overfit model is that student.
UNDERFIT GOOD FIT OVERFIT
(too simple) (the pattern) (memorised noise)
• • • • •__•
____•___ __/‾‾\__ _/‾\_•/‾\_
• • •/ \• •/ \•/ \•
(misses it) (smooth, general) (wiggly, brittle)
The cure is simple to state: always test the model on data it has never seen. You hold back some examples, train on the rest, then check the held-back set. If it does well on examples it studied but badly on the held-back ones — it overfit. This hold-back check (called validation) is non-negotiable. A model is only as good as its performance on data it has never seen.
- Overfitting = memorising the examples instead of learning the pattern
- An overfit model looks brilliant on training data and fails on new data
- Always measure on held-back ("validation") data the model never saw
- In the exam analogy, what does "overfitting" correspond to, and why does it fail?
- A teammate reports a model with 98% accuracy. What is the one question you must ask?
Judging a model with the right measure
"Accuracy" sounds like the obvious way to judge a model — what fraction did it get right? But accuracy can lie, badly. Suppose 1 in 1,000 transactions is fraud. A lazy model that says "never fraud" is 99.9% accurate — and completely useless, because it never catches a single fraud.
So we use sharper measures. The two that matter most:
- Precision — when the model raises an alarm, how often is it right? High precision = few false alarms.
- Recall — of all the real cases, how many did the model catch? High recall = few misses.
There is almost always a trade-off. Catch more fraud (high recall) and you will also flag more innocent transactions (lower precision). Which matters more depends entirely on the job:
- Accuracy is misleading when one outcome is rare (fraud, disease)
- Precision = how often alarms are right; recall = how many real cases you catch
- The right balance depends on the cost of a false alarm vs. a miss — a judgement call, not just maths