Text & documents
Numbers & maths
Data & formats
Security
Development & DevOps
Artificial Intelligence
Finance
Health & Wellness
Productivity
Games & Entertainment
Multimedia & design
Business
How to use
What it is and what it's for

Regression finds the curve that best fits a cloud of points, so you can predict the value y from an x. Each point is an observation (for example, study hours → grade); the fitted curve summarizes the trend and lets you estimate the y of an x you never measured. You see it live here: move points and the curve, the error and R² recompute instantly, all in your browser.

How to use it (step by step)

1. Drag any point to move it; the curve refits when you release.
2. Click on an empty spot of the chart to add a new point.
3. Move the Degree control to go from line to curve, and Regularization λ to smooth it.
4. Read the fit's MSE and below.
5. Buttons: Remove last deletes the last point, Clear deletes them all, and Reset returns to the starting example (10 points, degree 1, λ 0).

Linear regression (the line)

With Degree 1 the fit is a straight line y = a·x + b: classic linear regression. It's the simplest, most robust model: it captures the overall trend (whether y rises or falls as x grows, and with what slope) without being swayed by the noise of each point. Always start here; raise the degree only if the line clearly doesn't follow the shape of the data.

Least squares (how it fits)

The curve is chosen by least squares: it looks for the one that minimizes the sum of squared errors between each point and the curve (the residuals). They are squared so that errors above and below don't cancel out and so that large ones are penalized more. Internally it solves an exact linear system (normal equations), not by trial and error. Minimizing that error is equivalent to maximum likelihood (MLE) if the data noise is assumed to be Gaussian.

Polynomial degree and overfitting

The Degree (from 1 to 7) is how many bends the polynomial can make: degree 1 = line, 2 = parabola, and the higher the degree, the more wiggles. A high degree lowers the error on these points but usually gets worse: it overfits, i.e. it passes through almost every point chasing the noise and then generalizes poorly to new data. It's the bias-variance trade-off: too simple doesn't capture the shape, too complex memorizes the noise. Pick the lowest degree that follows the trend.

Residuals, MSE and R²

The vertical grey lines are the residuals: the distance from each point to the curve, i.e. the error the model makes at that point.

MSE (loss)mean squared error: the average of those squared residuals. Lower = better fit; it's exactly what the fit minimizes.
coefficient of determination: what fraction of the variation in y the model explains. It ranges from 0 to 1: 1 = the curve passes through every point, 0 = no better than always predicting the mean (and it can be negative if it fits worse than the mean itself).

Regularization λ (ridge = MAP)

Regularization λ (from 0 to 10) fights overfitting without lowering the degree: it penalizes the polynomial's large weights (ridge), which smooths the curve and makes it less sensitive to noise. At λ = 0 it's pure least squares; as λ rises, the curve flattens and tends toward a straight line. It's equivalent to adding a Gaussian prior on the weights: in Bayesian terms, you move from MLE to MAP. The penalty does not affect the independent term (intercept).

Regression & MLELeast squares, overfitting, ridge
Regression & MLELeast-squares fit, overfitting and regularization (ridge = MAP)

Drag the points. Click empty space to add a point. The gray lines are the residuals (each point's error).

Degree
1
Regularization λ
0
MSE (loss)0.236
0.942

Minimizing MSE = maximum likelihood with Gaussian noise (MLE). Raising the degree overfits noisy data; λ (ridge) is a Gaussian prior on the weights → MAP. It's the bias-variance trade-off.