RegressionSample
Linear regression
Fits the straight line that minimises the squared distance between predictions and the data.
Synthetic data, generated and trained in your browser.
Try this
- 01Switch the solver to gradient descent, then push the learning rate above 0.8: the line overshoots and the loss explodes.
- 02Pick the Outliers dataset and show residuals: four points drag the whole line down.
- 03Add a point far above the line on the right and watch the slope tilt towards it.
How it works
- 1Assume the target is a straight-line function of the input: y = w·x + b.
- 2Measure error as the mean of the squared residuals (MSE).
- 3Find w and b that minimise it, either in one step (closed form) or by repeatedly stepping downhill along the gradient.
- 4Predict new values by reading them off the line.
What the controls teach
- Solver
- Closed form jumps straight to the best line; gradient descent shows the path an optimiser takes to reach it.
- Learning rate
- How far each gradient step moves. Too small crawls; too large overshoots and diverges.
Use it when
- The relationship is roughly linear
- You need a fast, interpretable baseline
Avoid it when
- The pattern is clearly curved
- A few outliers dominate the data