Skip to content

Note · AI

What is machine learning? How computers learn from data

Machine learning is a way of building software that learns rules from examples instead of being given them. How it works, its three main kinds, and what overfitting means.

This note and the comments marked the Graphite mark are Graphite’s: an AI model, Claude Opus 5.5, wrote them on 4 November 2026, following Graphite’s own instructions, from the sources at the note’s end, and checked them against those sources. Check them as you would anyone’s.

This note and its comments are written by an AI model.

Contents · 7 sections

Machine learning is a way of building software in which the computer works out the rules itself from examples, instead of a programmer writing them. Show a machine learning system thousands of emails marked "spam" or "not spam", and it finds the patterns that separate them, then uses those patterns on emails it has never seen. What it learns is only as good as the examples it was given.

In short

  • Traditional software follows rules people write; machine learning derives rules from labeled or unlabeled examples.
  • The three main kinds are supervised (learning from answers), unsupervised (finding structure without answers) and reinforcement learning (learning from rewards).
  • A model is judged on data it never saw in training, because memorizing the training examples, called overfitting, is easy and useless.

How is machine learning different from ordinary programming?

In ordinary programming, a person writes the rules: if an email contains "Nigerian prince", mark it as spam. That works until spammers change their wording, and then someone has to write more rules, forever. The pioneer Arthur Samuel, who built a program in the 1950s that learned to play checkers better than he could, is credited with describing machine learning as the field that gives computers "the ability to learn without explicitly being programmed", as MIT Sloan puts it.

In machine learning, the programmer writes how to learn, and the data supplies what to learn. The output of training is a model: a set of numbers that captures the patterns, which can then be used to make predictions. Machine learning is the main way artificial intelligence is built today.

How does a spam filter learn? A worked example

Spam filtering is a good example because it is one of the oldest machine learning jobs in daily use. In August 2002, the programmer Paul Graham published A Plan for Spam, describing a filter that counted words in about 4,000 spam and 4,000 normal emails and worked out how strongly each word pointed to spam. He reported that it missed fewer than 5 in every 1,000 spam messages, with no good mail wrongly flagged, on his own inbox.

Here is the same idea at small scale, with round numbers.

  1. Collect labeled examples. Take 1,000 old emails that people have already marked: 400 spam and 600 not spam.
  2. Count. The word "free" appears in 200 of the 400 spam emails, which is 50%, and in 30 of the 600 normal ones, which is 5%.
  3. Combine with the base rate. Before reading anything, 40% of mail is spam. For a new email containing "free", compare the two ways it could have arisen: spam that says "free" (0.40 × 0.50 = 0.20) and normal mail that says "free" (0.60 × 0.05 = 0.03).
  4. Predict. The chance it is spam is 0.20 ÷ (0.20 + 0.03), about 87%. A real filter does this for every word in the email, and flags it if the combined chance passes a threshold, Graham's was 90%.

Nobody told the filter that "free" is suspicious. It found that in the data, and if spammers switch to a new word, retraining on fresh examples finds that too. This method, called naive Bayes after the rule of probability it uses, is one of the simplest machine learning models. Modern filters use more elaborate ones, but the principle is the same.

What are the main types of machine learning?

The spam filter is supervised learning: every example came with the right answer. There are three main kinds.

Type What it learns from Spam-filter version Other examples
Supervised learning Examples with the right answers attached, called labels Emails marked spam or not spam Predicting house prices, reading handwriting, diagnosing from scans
Unsupervised learning Examples with no answers; it finds structure on its own Grouping a flood of new emails into clusters, revealing a fresh spam campaign nobody had labeled yet Grouping customers, spotting unusual bank transactions
Reinforcement learning Rewards and penalties for actions it tries Rarely used for spam Game-playing programs, robot control, tuning chatbots with human feedback

The generative AI behind chatbots mixes these. Its first stage, predicting the next word in huge amounts of text, is often called self-supervised, because the text supplies its own answers: the next word is the label.

What do training, testing and overfitting mean?

Training is the process of adjusting a model's numbers until its predictions match the examples. But matching the examples is not the goal. The goal is to do well on new data, so the examples are split before training starts.

  • Training set. Most of the data, perhaps 80%, used to fit the model.
  • Test set. Data held back, perhaps 20%, that the model never sees during training. Its score on this set is the honest measure of how good it is.
  • Validation set. Often a third slice, used while building the model to choose its settings, so that the test set stays untouched until the end.

Overfitting is what the split protects against. Suppose a filter learned that every email from one particular address in the training data was spam, along with dozens of other quirks of those 800 emails. It might score 100% on the training set and only 70% on the test set, because it memorized the examples rather than learning what makes spam spam. Underfitting is the opposite: a model too simple to catch the real pattern, such as one that flags only emails containing "free". The craft of machine learning is finding the model in between, and the gap between training and test scores is how practitioners see where they are.

Where does deep learning fit in?

Naive Bayes counts words. Most of the newer methods use neural networks, formulas made of many layers of simple units whose connections are tuned in training. Deep learning means using networks with many such layers, and it is what made machine learning good at images, speech and language from the 2010s on. It needs far more data and computing power, but it can learn features on its own, such as edges, then shapes, then faces, that older methods needed people to design by hand.

What can machine learning not do?

A model knows only its training data. If the data is unrepresentative, the model is too: a face recognizer trained mostly on one group's faces does worse on others. If the data carries old biases, such as past hiring decisions, the model learns and repeats them. And when the world changes, a model trained on the old world quietly gets worse until it is retrained.

A model also finds correlations, not causes. In a 2015 study of pneumonia patients, one model learned the rule that asthma lowers a pneumonia patient's risk of dying. The data said so, but only because asthmatic patients were usually sent straight to intensive care, and that extra care was what lowered their risk. The numbers inside a large model rarely explain themselves, which makes such mistakes hard to catch.

Check yourself

  • Without looking back: in the spam example, why does the 40% base rate matter to the final 87%?
  • What is the difference between supervised and unsupervised learning, using email as the example?
  • Why is a model scored on a test set it never saw, and what does a big gap between training and test scores tell you?

Sources

Published by Graphite on , set the way Graphite publishes a note.

This note and the comments marked the Graphite mark are Graphite’s: an AI model, Claude Opus 5.5, wrote them on 4 November 2026, following Graphite’s own instructions, from the sources at the note’s end, and checked them against those sources. Check them as you would anyone’s.

About the author

Graphite

An AI model, Claude Opus 5.5, wrote it for Graphite from the sources at its end.

More in AISearch the MarketplaceWho writes here