Technology & Computing · AI & machine learning
How machine learning works
A machine-learning system isn't given the rules. It's shown examples and adjusts itself until its guesses improve. See how training works, why a model can ace its lessons and fail in the world, and how it's tested.

What you will learn
- Name the features, label and learned numbers in a simple model
- Describe how training lowers a model's loss step by step
- Explain what overfitting is and why it fails on new data
- Explain why a model must be tested on data kept apart from training
Lesson 1 of 4 · 4 min
How a model learns a car's mileage from examples
The term machine learning was coined in 1959 by Arthur Samuel, an IBM researcher working on checkers. It means software that learns from data and then handles new data, so it can do a task without being explicitly programmed.
Say you want an app that predicts rain. One route is to write physics equations for the whole atmosphere, which is very hard. The machine-learning route is to give a model huge amounts of weather data until it learns how weather patterns relate to rainfall.
The most common kind is supervised learning. Each training example has features and a label. Features are the values the model uses to predict. The label is the right answer it's trying to predict.
Google's machine learning course uses cars. The feature is a car's heaviness, and the label is its real miles per gallon. Heavier cars generally get fewer miles per gallon, so the course fits a straight line through seven cars.
That line is the model. It predicts mileage as 34 minus 4.6 for every thousand pounds. The negative 4.6 is a learned number called a weight, and the 34 is another called the bias. A 4,000-pound car gets a predicted 15.6 miles per gallon.
Where do 34 and 4.6 come from? The model finds them by shrinking its loss, a number for how wrong its predictions are. For a 2,370-pound car, the line predicts 23.1 miles per gallon. The car really gets 24. Squaring the gap of 0.9 gives a loss of 0.81 for that car.
Training starts with both numbers at zero. With both at zero, the model predicts zero miles per gallon for every car, and its average squared loss on the seven cars is 303.71.
Then a method called gradient descent repeats four steps. Work out the loss with the current numbers. Work out which direction to nudge them to lower it. Move them a small amount that way. Repeat until the loss stops falling, at which point the model has converged.
Try to recallHow does gradient descent find good numbers for a machine-learning model?
It starts with the model's numbers near zero and measures the loss, how wrong the predictions are. It works out which direction to nudge the numbers to lower the loss, moves them a small step and repeats. It stops when the loss won't fall any further.
A supervised model predicts a label from features using numbers it learns. Training finds those numbers by measuring the loss and nudging the numbers downhill until it stops falling.
Lessons in this topic
How a model learns a car's mileage from examples
Follow a simple model from blank numbers to useful predictions, and see what it means to shrink the error.
When a model memorizes instead of learning
See why a model can ace its training data and fail on new data, and how keeping some data unseen catches it.
Learning with no answers and learning by reward
See how a model can find groups in data nobody labeled, and how a game-playing system learns from rewards alone.
Why a model is only as good as its data
See how true patterns in data can still mislead a model, and how differences between training data and real use break it.
Three quick stories from this topic
Where the name came from
The term machine learning was coined in 1959 by an IBM researcher working on checkers
Arthur Samuel's checkers program remembered positions it had already seen. He also had it play thousands of games against itself as another way to learn, an idea game-playing systems still use.
No explicit program
Machine learning means software that learns from data and handles data it hasn't seen, so it can do tasks without being explicitly programmed.
Still the same loop
A modern model still learns by adjusting its numbers to shrink a measure of how wrong its predictions are.
The self-taught backgammon player
A backgammon program that played 1.5 million games against itself changed how experts open
Gerald Tesauro's TD-Gammon trained against itself in 1993 and reached a level just below the top human players. Expert players accepted and adopted its unconventional assessment of some opening strategies.
Rewards, not answers
Reinforcement learning gets a reward instead of correct answers. The learner finds which actions pay by trying them.
Rewards can misfire
A simulated bicycle rewarded for heading toward a goal, and never penalized for heading away, learned to ride in circles.
X-rays that name their hospital
Pneumonia-spotting AI could tell which hospital an X-ray came from over 99.9% of the time
In a 2018 study of 158,323 chest X-rays, pneumonia showed up in 34.2% of one hospital's images and about 1% of the others'. Knowing the hospital was a shortcut, and the models did worse at outside hospitals.
A clue that doesn't travel
The hospital gave the models a clue in training. At a new hospital the clue didn't hold, so accuracy fell.
Data decides
A model uses any pattern that works in its data, including where the data came from.
Sources
- Machine learning, Wikipedia
- What is Machine Learning?, Google for Developers, Machine Learning Crash Course
- Supervised Learning, Google for Developers, Machine Learning Crash Course
- Linear regression, Google for Developers, Machine Learning Crash Course
- Linear regression: Loss, Google for Developers, Machine Learning Crash Course
- Linear regression: Gradient descent, Google for Developers, Machine Learning Crash Course
- Arthur Samuel (computer scientist), Wikipedia
- TD-Gammon, Wikipedia
- Variable generalization performance of a deep learning model to detect pneumonia in chest radiographs, Zech and others, PLOS Medicine, 2018





