Imagine you had to write a spam filter the old-fashioned way: read a pile of emails yourself, and type out a rule for every trick spammers use. "If it contains the word lottery, flag it." "If it has five exclamation marks in the subject line, flag it." "If it's from an address full of random numbers…" You'd write rule after rule, and spammers would keep inventing new tricks you never thought to cover. It's a losing battle.
Machine learning solves this a completely different way. Instead of you writing the rules, you show the computer thousands of real emails, each one already marked "spam" or "not spam" — and the computer works out its own rules for telling them apart, by noticing patterns you might never have spotted yourself. It's learning from examples, not from hand-written instructions.
This is such a different way of building software that it's worth spelling out the swap exactly.
For the spam filter: in traditional programming, you are the one squinting at emails and typing "if it says lottery, flag it." In machine learning, you hand over a big stack of emails already labelled spam or not-spam, and the computer itself discovers that emails mentioning lotteries, urgent bank transfers, or "click here now!" tend to be spam — often finding subtler clues than any human bothered to write down, like which combinations of words tend to appear together in junk mail. Once it has learned those rules, it can apply them to a brand-new email it has never seen before.
The same swap shows up anywhere a pattern is real but too slippery to write down as a checklist. A bank wanting to catch fraudulent credit-card transactions could try to hand-write rules — "flag any purchase over $500 made abroad" — but fraudsters adapt within days, and honest customers keep genuinely travelling and buying expensive things. Instead, banks show a model millions of past transactions labelled "genuine" or "fraudulent," and let it work out the subtle combinations — this merchant type, at this time of night, at this distance from the cardholder's usual city — that tend to signal trouble, updating that pattern automatically as fraud evolves.
Here's the same idea in miniature, with numbers instead of words. Suppose you want a program that guesses how much a house will sell for. You don't know a formula for house prices — but you do have a list of houses that already sold, together with their sizes and their sale prices. Each dot below is one of those real sales: how big the house is along the bottom, what it actually sold for up the side.
A machine learning model's job is to find a rule — here, just a straight line — that fits those sales as closely as possible. Once it has that line, it can read off a sensible price guess for a house it has never seen sold, just by looking at its size.
Adjust the slope and height of the line to make it hug the dots. The faint sticks are the errors — how far each real sale sits from your line — and the total is shown below. Shrinking that total is exactly what a learning algorithm does inside a computer: it nudges the line back and forth, checking the total error each time, until no small nudge makes things any better. You just did, by hand and by eye, what an algorithm does automatically, in a fraction of a second, on data sets with millions of houses and dozens of features instead of one.
Not every problem needs a learning machine — plenty of everyday tasks are still best solved by writing an ordinary program with clear, exact rules. The test is: can you write down an exact, complete rule yourself — or is the pattern too fuzzy, too full of exceptions, or too vast to spell out by hand?
A human toddler can learn what a "dog" looks like from meeting two or three real dogs — but a computer vision model learning the same thing from scratch typically needs thousands, sometimes millions, of labelled photos before it reliably tells dogs from wolves, foxes and the neighbour's oddly-shaped cat. Human brains arrive already loaded with millions of years of evolved shortcuts for seeing the world; a fresh machine learning model starts knowing precisely nothing, so it has to squeeze every scrap of its knowledge out of the examples it's shown.
More examples usually make a model's learned rule steadier and more reliable, in the same way that guessing the average height of your class from thirty measurements beats guessing it from just two. But quantity is not the whole story: a huge pile of low-quality or narrow examples can teach a worse rule than a smaller, carefully chosen, varied one — which is exactly the trap in the next section.
Machine learning is not magic, and it doesn't invent knowledge from nowhere. A model can only learn patterns that are genuinely present in the examples it was shown — nothing more. Two consequences of this catch people out constantly:
A learning machine is only ever as good, and as fair, as the examples it is trained on.
Not quite — the two words get used interchangeably in headlines, but they mean different things.
Artificial intelligence (AI) is the whole, very old ambition of getting machines
to do things that seem to require intelligence — the field dates back to
Machine learning is one hugely successful approach within that broader field — the "learn the rules from data" approach, rather than "hand-write the rules yourself." It's fair to say every machine learning system is a form of AI, but not every AI system uses machine learning, and not everything people market as "AI-powered" today is actually learning from data at all.
In 1959, an IBM researcher named Arthur Samuel wrote a program that played checkers — and got better at it not because he improved the code, but because he let it play against itself, thousands and thousands of games, quietly adjusting its own strategy after every loss. Eventually it could beat strong amateur players, including, reportedly, Samuel himself. He needed a name for what the program was doing, since he certainly hadn't typed in a winning strategy by hand — and he called it "machine learning," coining the very term this page is named after.
You brush past machine learning like this constantly today without noticing: your phone's keyboard quietly learns your typing quirks for autocorrect, your camera app learns to recognise faces in photos, and a streaming app learns what you tend to enjoy — each one running its own small Arthur-Samuel-style loop, learning from a mountain of examples instead of a mountain of hand-typed rules.
Once a model has learned a good rule from past examples, it can make predictions about new ones it has never seen. That's the whole game: learn a pattern from data, then use it on the future. Spam filters, house-price estimators, recommendation engines, medical diagnosis, speech recognition — all are this same loop, scaled up to millions of examples and far more complicated patterns than a straight line.
A radiologist-support tool, for instance, learns from thousands of X-ray images that doctors have already labelled "shows a fracture" or "looks clear," and can then flag a suspicious new scan for a human doctor to double-check. A speech-recognition system learns from hours of recorded audio that a human has carefully typed out word for word, so it can later turn a stranger's brand-new sentence into text. A shopping app learns from millions of past star-ratings so it can guess, for a product you've never rated, roughly how many stars you'd give it. Every one of these is still the same simple idea from the house-price example: gather examples with known answers, find the pattern connecting them, then apply that pattern to something new. Everything in this course is a richer version of "find the rule that best fits the examples."