)
Series 1 · Machine Learning Fundamentals

Traditional Programming vs. Machine Learning

In traditional programming a human writes the rules; in machine learning you feed the machine examples and it works out the rules for itself.

← All topics
Side-by-side comparison of traditional programming and machine learning for the same prediction task.

Take the example from the previous chapter: given someone’s age, gender, and body mass index, predict their life expectancy and the total health-care cost up to death. There are two completely different ways to build that predictor.

Traditional programming. A human analyst studies the problem and works out the rules — the algorithm that turns inputs into an output. They write those rules down explicitly (if age < 50 and gender = Female and BMI > 20, then life expectancy = 85 years and cost = 300k), test them against historical data, refine them where they’re wrong, and ship. The intelligence lives in the rules, and a person had to supply it.

Machine learning. Instead of writing the rules, you choose a model: a general set of formulas that depends on a set of free parameters, usually called weights. The model doesn’t know anything yet. You then train it — tune those weights — using known examples (the training set) so that its output reproduces the observed reality as faithfully as possible. You hold back a small portion of the data for a final test, go back and correct the model if needed, and ship. Nobody wrote the rules; they’re encoded in the weights the machine found through this optimization process.

The cleanest way to see the difference is to look at what goes in and what comes out.

Classical programming takes rules and data to produce answers; machine learning takes data and answers to produce rules.
The same ingredients, swapped around: classical programming turns rules + data into answers; machine learning turns data + answers into rules. Concept from Chollet, F. (2017), Deep Learning with Python, Manning Publications, fig. 1.2.

Classical programming consumes rules + data and produces answers. Machine learning consumes data + answers and produces the rules.

One consequence is worth emphasizing, because it explains a lot of what follows: the same model, trained on a different training set, ends up with different weights and can describe a completely different problem. The formulas that predict life expectancy and health-care costs from age, gender, and BMI could, with different weights, predict whether a flower is a rose or a geranium from the characteristics of its petals. The structure is generic; the meaning is entirely in the values of the weights.

That is why, over the last couple of decades, for prediction problems machine learning has increasingly won out over programming based on explicit rules (so-called expert systems): computing power stopped being the bottleneck, data became available in quantities previously unimaginable, and letting the data write the rules scales in a way no analyst could match.

Nested circles: artificial intelligence contains machine learning, which contains deep learning, which contains generative AI; the neural network underlies them all.
Machine learning is one way to build AI; deep learning is machine learning with multiple processing layers; generative AI lives inside that — and the neural network is by far the most widely used technical solution for implementing this class of algorithms.

Machine learning is only one region of a bigger map. It is one of the ways to implement artificial intelligence, and now the most common one; deep learning is a particular class of machine learning; generative AI builds on deep learning to solve generation problems — and nearly everything we’ll cover is built on one piece of technology, the neural network, which is where this series goes next.