Regression
Regression predicts a number, such as a house price, a tree's life span or a rainfall total, from an example's features.
Regression is supervised learning where the answer is a number. Each training example pairs features with a known number, its label. The model learns a function that turns a new example’s features into an estimate on the same scale as that label. Classification is the sibling task: it picks a class, such as a tree species, rather than a number.
Linear regression is the simplest picture: multiply each feature by a learned weight, add the results and add a bias. Other regressors use decision trees, ensembles or neural networks, which can follow stepped or curved patterns, so regression does not mean the relationship must be a straight line.
Training needs a definition of wrong. Mean absolute error averages the size of misses. Mean squared error squares each miss before averaging, so a few large errors pull harder on the model. An optimizer such as gradient descent repeatedly measures loss and adjusts parameters. A low training loss is not the finish line, though. The real test is how well the model does on examples it never saw during training.
Many useful predictions are quantities, not category names.
Follow one house from features to a price estimate.
- 1 · representDescribe each example with features, and pair every training example with its known answer, the label.
- 2 · predictA regression function combines the features to produce a numerical estimate.
- 3 · compareA loss function measures the difference between each estimate and its known label.
- 4 · adjustTraining changes model parameters in a direction that reduces that loss.
Classification picks a class; regression places the answer on a number line.
| Who | What they ask | What it works with |
|---|---|---|
| Property analyst | “What is this home likely to sell for?” | Size, location, age and comparable sales |
| Delivery team | “How many minutes will this route take?” | Distance, traffic and stop count |
| Energy planner | “How much electricity will this building use tomorrow?” | Weather, calendar and meter history |
| Manufacturer | “How many hours remain before this part fails?” | Sensor readings and maintenance history |
- Regression estimates numerical labels from features.
- Linear regression assigns a learned weight to each feature and adds a bias.
- Loss makes prediction error measurable during training.
- Regression can use non-linear models, such as trees and neural networks, as well as linear ones.
- A standard regression model returns one number with no error bars; measuring its uncertainty takes extra methods.
- A low training loss does not show that the model will generalize to new examples.
- Mean squared error gives large misses extra influence, which may be undesirable when outliers are not representative.
- The learning rate, batch size and number of epochs are choices made outside the fitted model parameters.
Sources used
This explainer is written in original language. The links below support its factual claims.
- docsLinear regression, Google for Developers · read 27 Sept 2026
- docsLinear regression: Loss, Google for Developers · read 27 Sept 2026
- docsLinear regression: Gradient descent, Google for Developers · read 27 Sept 2026
- docsLinear regression: Hyperparameters, Google for Developers · read 27 Sept 2026
- docssklearn.ensemble, scikit-learn developers · read 27 Sept 2026
- docsMachine Learning Glossary, Google for Developers · read 27 Sept 2026
- docsDecision Trees, scikit-learn developers · read 27 Sept 2026
- docsNeural network models (supervised), scikit-learn developers · read 27 Sept 2026