Make a prediction
Linear Regression
Fit a line to editable data and see how residuals, mean squared error, and gradient descent describe the same learning process.
Experiment controls
Click empty space to add a point. Drag a point to move it. Shift-click a point to remove it.
Prediction line and residuals
The vertical segments are residuals: the difference between an observed value and the model prediction.
Loss surface
Drag or use the arrow keys to rotate. Height represents training loss; the red marker is the current model and the yellow line records gradient-descent steps.
What the model is calculating
A line makes one prediction at every horizontal position. Learning means adjusting its slope and intercept so the residuals become small overall—not necessarily zero for every point.
Select One influential outlier, choose Show best fit, then drag the isolated point. Watch the line and test error respond.
Select or add a point to inspect its calculation.
For mean squared error, the gradient measures how a tiny change in each parameter would change the loss. One update is:
- A very small learning rate moves safely but slowly.
- A very large learning rate can overshoot or diverge.
- The closed-form best fit and converged gradient descent solve the same least-squares problem here.
- A low training error does not guarantee a good model for unseen data.
Logistic Regression
Turn a weighted score into a probability, then see how a decision threshold converts that probability into one of two classes.
Experiment controls
Choose a class, then click to add a point. Drag any point to move it. Shift-click to remove it.
Probability map and decision boundary
Colour shows the model's probability for Class 1. The solid line marks the selected decision threshold.
The sigmoid function
Select or add a point to inspect its score and probability.
Confusion matrix
Move only the threshold to change decisions while leaving every learned probability unchanged.
From score to class
The weights tilt a smooth probability surface across the feature space. The threshold slices that surface to produce a decision boundary: one side becomes Class 0 and the other Class 1.
Select Overlapping classes, auto-step briefly, then move the threshold from 0.30 to 0.70. Compare precision, recall, and the two kinds of error.
Select or add a point to inspect its calculation.
Cross-entropy strongly penalises confident probabilities that are wrong. One gradient step changes the weights and bias in the direction that lowers this loss.
- The decision boundary is linear even though the probability is produced by a curved sigmoid.
- Threshold choice changes decisions and metrics, but it does not retrain the model.
- Accuracy can hide poor performance on an imbalanced dataset.
- A nonlinear pattern reveals a limitation of a single straight boundary.