03 · Learning path
Linear Regression
The simplest model for predicting a continuous variable by fitting the best line to the data.
Linear regression looks for the line that best fits a set of points. It is the foundation of much of modern machine learning and the standard tool for predicting numerical values.
Experiment with the OLS line
Draw points and watch the line refit automatically by ordinary least squares (OLS).
Regression lab
Ordinary least squares
Model
Goodness of fit
R² = 0.656
This line minimizes the sum of squared residuals.
Variance
β₁ (OLS)
0.540
β₀ (OLS)
21.7
Minimum SSE
937
- OLS line
- Your line
- OLS (reference)
What to look for
- R² = 1 − SSE/SST: how much variance the line explains compared with using only the mean.
- Each square has a side equal to the residual; its area is its contribution to the SSE.
- In manual mode, try to match the minimum SSE by moving both sliders.
The model
With one explanatory variable
where
OLS chooses the coefficients that minimize the sum of squared errors (SSE):
In the simple case there is a closed-form solution, and it connects with the earlier concepts:
How well it fits
The coefficient of determination
In simple regression,
Applications
From predicting the price of a house from its square footage to estimating the effect of a marketing campaign on sales.