Draw a candidate line.
Every point gets a prediction from y = mx + b. At first it can be completely wrong. That is the point: the model has a visible place to improve from.
ML from scratch, in the browser
Set a tiny dataset. Calculate the error. Move the line. This is linear regression without a wrapper, so every update has a reason.
A working notebook
y = 0.000x + 0.000
The loop, named
Every point gets a prediction from y = mx + b. At first it can be completely wrong. That is the point: the model has a visible place to improve from.
Each update records a real mean-squared error.
Mean squared error makes large misses matter more. The value is not invented feedback; it is recalculated from the exact points and line in your experiment.
The two gradients say how loss changes when slope or intercept move. Multiply by the learning rate, subtract, repeat. Smaller steps are steadier; oversized steps can miss the valley.
A durable mental model
scikit-learn and PyTorch let you move fast. This lab is not a replacement for them. It is a compact way to connect the convenience of an API call to the predictions, loss, and parameter updates it orchestrates.
Change the data, start from a strange slope, then download the evidence of what happened. A short experiment can make the next training loop feel less like a black box.
Keep the evidence