Free sample lesson · How Machine Learning Models Learn
What It Means to Learn From Data
A physics-based rain forecast solves huge numbers of fluid dynamics equations about the atmosphere. A machine learning forecast skips the equations. It looks at lots of past weather records, keeps comparing its guesses with how much rain actually fell, and adjusts itself each time it misses. Nobody types in the rule linking weather to rain, yet the model ends up with one. How does it get there?
Lesson 1 of the Wondering course How Machine Learning Models Learn
A Relationship From Data
How can software predict rain without receiving a weather-to-rain rule?
Traditional forecasting solves huge numbers of fluid dynamics equations. Machine learning instead learns a mathematical relationship from past weather and rainfall data.[[1]](https://developers.google.com/machine-learning/intro-to-ml/what-is-ml?hl=en)
- Traditional forecasting
- Machine learning
That learned relationship is called a model. A spreadsheet formula written by a person is different because examples never corrected it.
Guess, Compare, Adjust
Suppose the model predicts 2 mm of rain for a humid day, but the record says 8 mm fell.
The model compares its prediction with the known answer. It then adjusts its relationship so humid days predict more rain.
For a dry day, 5 mm predicted versus 0 mm actual pushes it the other way. Repeated corrections gradually shrink its errors.[[1]](https://developers.google.com/machine-learning/intro-to-ml/what-is-ml?hl=en)
- Predict: Guess rainfall, e.g. 2 mm for a humid day.
- Compare: Check the guess against the record: 8 mm actually fell.
- Adjust: Shift the relationship so humid days predict more rain; a dry day's 5 mm vs 0 mm pushes the other way.
Data Shapes the Model
What happens if many recorded rainfall answers are wrong?
The model still follows the same cycle. It compares each guess with the supplied answer, then adjusts toward that answer, even when the answer is mistaken.
Training therefore produces a relationship shaped by its data. The model does not understand why rain falls; it only changes until its predictions match the training answers well.
Two Supervised Predictions
Does the required answer look like a number or a category?
Regression predicts a number, such as rainfall in millimeters, a house price, ride time, or building energy use.[[1]](https://developers.google.com/machine-learning/intro-to-ml/what-is-ml?hl=en)
Classification predicts a category. Spam or not spam is binary classification; rain, hail, snow, or sleet is multiclass classification.
A category coded as 1 or 2 remains classification.
- Supervised prediction
- Regression: Predicts a number.
- Rainfall in mm
- House price
- Ride time
- Building energy use
- Classification: Predicts a category, even if coded as 1 or 2.
- Binary: Spam or not spam.
- Multiclass: Rain, hail, snow, or sleet.
Learning Without Answers
What if weather records arrive without rainfall amounts or weather-type answers?
Unsupervised learning has no correct answers for checking guesses. It searches for structure, often by grouping similar records into clusters.[[1]](https://developers.google.com/machine-learning/intro-to-ml/what-is-ml?hl=en)
A clustering model can find groups in weather data; a person adds meanings such as snow, rain, sleet, or no rain afterward.

A clustering model groups similar weather data; the names snow, rain, sleet, and no rain are added by a person afterwards. · Google for Developers, Introduction to Machine Learning (CC BY 4.0) · CC BY
Clusters do not name themselves.
Classification or Clustering?
Both classification and clustering create groups, so what separates them?
Classification uses categories defined beforehand and examples that come with correct answers. Predicting spam or not spam is binary classification; predicting four weather types is multiclass classification.[[1]](https://developers.google.com/machine-learning/intro-to-ml/what-is-ml?hl=en)
Clustering receives no category answers. Grouping shoppers or weather records by similarity is clustering, and a person interprets the resulting groups.
- Classification
- Clustering
The Same Foundation
How do other learning approaches fit this picture?
Reinforcement learning adjusts behavior using rewards and penalties rather than answer keys. Generative AI, including LLMs, learns to produce new data resembling its training data and may later use supervised or reinforcement learning.[[1]](https://developers.google.com/machine-learning/intro-to-ml/what-is-ml?hl=en)
Model choice starts with the available feedback: numeric answers, category answers, no answers, or rewards. Next, supervised examples separate into features and labels.
Check yourself
A rain-prediction model trained on past weather data learns its weather-to-rain relationship from examples rather than receiving a rule written by a programmer.
- True
- False
Answer: True
This is correct. Machine learning trains a model by learning a mathematical relationship from data. A hand-coded system instead follows rules written by a programmer.
During supervised training, the model first _____ an answer, then _____ it with the known answer, and finally _____ its relationship.
Answer: During supervised training, the model first predicts an answer, then compares it with the known answer, and finally adjusts its relationship.
The training cycle is predict, compare, and adjust. Repeating this cycle reduces mismatches between predictions and known answers.
Which task is a regression problem?
- Predicting a building’s energy use in kilowatt-hours
- Sorting email into spam or not spam
- Grouping weather records by similarity
- Predicting whether rain, hail, snow, or sleet will occur
Answer: Predicting a building’s energy use in kilowatt-hours
Regression predicts a number. Building energy use in kilowatt-hours is numeric, while spam detection predicts categories and grouping records by similarity is clustering.
Keep going
This is lesson 1 of 10 in How Machine Learning Models Learn. Next up:
- Turning the World Into Features
- A Straight Line Is a Model
- Measuring Wrongness With Loss
- Gradient Descent: Training Step by Step
- When a Model Memorizes Instead of Learns
Wondering turns any topic into short lessons you can read, watch, or listen to, with practice questions and an AI tutor.