Learning from examples
Most traditional software follows rules that a programmer writes out in full: if this happens, do that. This works well when the rules are clear. It works badly when the rules are hard to state. Try writing exact instructions for telling a photo of a cat from a photo of a dog, or for deciding whether an email is junk. There are too many exceptions.
Machine learning takes a different route. Instead of writing the rules, you give a program many examples and a way of measuring how well it is doing, and the program adjusts itself to find patterns that work. The result is sometimes called a model: a set of numbers, adjusted during training, that turns an input into an output.
Machine learning is one approach within the wider field covered in the overview of artificial intelligence. Not everything called AI uses it, but it is behind much of what is currently in the news.
A simple example
Consider a spam filter. Developers collect a large set of emails that people have already marked as spam or not spam. Each email is turned into numbers, for instance counts of certain words, which is possible because all digital data can be represented as binary code. The learning system starts with a model that guesses poorly. For each example, it compares its guess with the known answer and nudges its internal numbers to reduce the error. After going through the data many times, the model tends to catch patterns, such as certain phrases appearing more in junk mail.
No one wrote a rule saying “emails containing this phrase are spam.” The system worked out which signals matter and how strongly, from the data.
The pieces of the process
- Data: the examples to learn from. The quality and variety of the data largely decide the quality of the result.
- Model: the structure that makes predictions. It can be as simple as a straight line fitted to points or as large as a network with millions or billions of adjustable numbers.
- Training: the stage where the model’s numbers are adjusted to reduce its mistakes, using a measure of error and a mathematical method for deciding which direction to adjust. The ideas draw on statistics and calculus, a good example of everyday mathematics behind modern tools.
- Testing: checking the trained model on new examples it has never seen. This is what shows whether it has truly learned something general.
Main kinds of learning
Supervised learning uses examples labeled with correct answers, as in the spam filter. It is used for tasks such as classification (which category?) and prediction of numbers (how much?).
Unsupervised learning has no labels. The system looks for structure by itself, such as grouping similar customers or finding unusual items.
Reinforcement learning has the system try actions and receive rewards or penalties, gradually learning which choices lead to better outcomes. It is used in some game-playing and control problems.
There are other variations, including approaches that combine these ideas.
Neural networks
A neural network is a type of model made of layers of simple connected units. The name is a loose inspiration from the brain, but these systems are mathematical functions, not copies of biological neurons. During training, the strengths of the connections between units are adjusted. Networks with many layers are often called deep learning, and they have been especially successful with images, speech and text.
Common problems
Overfitting happens when a model learns the quirks of its training examples, including noise, instead of the underlying pattern. It does very well on the data it has seen and poorly on new data. This is why testing on separate data matters.
Biased or unrepresentative data leads to biased results. If the examples reflect past human decisions or leave out certain groups, the model can reproduce or amplify those patterns. The effect resembles what psychologists describe as cognitive bias, except that here it enters through the data and design rather than through a person’s thinking.
Lack of understanding. A model finds statistical patterns. It does not necessarily understand why they hold, and it can fail unexpectedly when conditions change or when inputs look unlike its training data. Whether such systems count as machine thinking is a separate question that depends heavily on how thinking is defined.
Explainability. With large models, it can be difficult to say exactly why a particular answer was produced, which matters in high-stakes uses like medicine or lending.
What it is good for, and what it is not
Machine learning tends to work well when there is plenty of relevant data and the task is mostly about recognizing patterns: recommending items, recognizing speech, flagging unusual transactions, translating text. It is a poor fit when data is scarce, when the rules are already simple and known, or when mistakes are very costly and need clear explanations.
Training large models can require lots of computing power, often run on cloud computing services, and therefore a good deal of electricity. How well any system works also depends on how carefully it was built and checked, so results should be treated as estimates rather than certainties.