ML from scratch, in the browser

See the learning loop your libraries usually hide.

Set a tiny dataset. Calculate the error. Move the line. This is linear regression without a wrapper, so every update has a reason.

loss is a landscapefollow the slope

A working notebook

Start with points. End with the line they teach.

Step0
MSE loss-
Slope0.000
Intercept0.000
Gradient, slope-
Gradient, intercept-

y = 0.000x + 0.000

The loop, named

Libraries are useful. Understanding their moves is useful too.

1. Predict

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.

Each update records a real mean-squared error.

2. Measure

Turn misses into one loss.

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.

3. Update

Walk opposite the gradient.

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

Use the abstraction after you can inspect it.

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

Run a small model. Export a real record.

Back to the lab
Super generates helpful tools and automates fact-checking across the internet proactively. If you enjoyed this tool, build your own with Super and share it with a friend.