How does regression work?
Each training row pairs inputs with a known number, the setup of supervised learning, and the model fits a function that keeps a loss such as mean squared error as low as possible. Linear regression, the most common type, predicts a weighted sum of the inputs plus an intercept, so each coefficient reads as “one more unit of this input adds this much to the outcome”. When the relationship curves, polynomial terms, tree ensembles or a neural network take over, and ridge and lasso add regularization. The inputs you choose usually matter more than the algorithm, the work of feature engineering.
Regression vs classification: what is the difference?
The output. Regression returns a number, classification returns a category.
| Regression | Classification | |
|---|---|---|
| Output | A continuous number | One of a fixed set of labels |
| Example | Units sold next week | Will this customer churn? |
| Typical methods | Linear, ridge, lasso, tree regressors | Logistic regression, tree classifiers |
| Typical loss | Mean squared error | Log loss (cross-entropy) |
| Metrics | MAE, RMSE, R squared | Accuracy, precision, recall |
Logistic regression is a classifier despite its name. It “is implemented as a linear model for classification rather than regression” (scikit-learn 1.9.1 linear models guide, read 5 November 2026): it outputs a probability between 0 and 1, and a threshold turns that into a label.
How do you evaluate a regression model?
With error metrics on data the model never trained on.
| Metric | What it measures | How to read it |
|---|---|---|
| MAE | Mean absolute error | The typical miss, in the target’s units |
| RMSE | Root of mean squared error | Same units, large misses weigh more |
| R squared | Share of variance explained | 1.0 is perfect, 0.0 matches predicting the average |
R squared has no floor: its “best possible score is 1.0 and it can be negative” (scikit-learn 1.9.1 model evaluation guide, read 5 November 2026). Pick the metric whose errors cost what yours cost: RMSE when one large miss hurts, such as a stockout, MAE when every unit off costs the same. Training-set scores flatter through overfitting.
Where do businesses use regression?
Wherever a decision waits on a number. Demand forecasting sets stock and staffing, pricing models estimate what a market will bear, logistics teams predict delivery times, and finance projects customer lifetime value. Much predictive analytics is regression under another name. A forecast is only usable with its error attached: 1,200 units plus or minus 150 is a plan, 1,200 alone is a guess. “Regression testing” is an unrelated software idea, rerunning checks to catch a change that broke what used to work; for prompts and models see prompt regression testing.