ONE PIXEL / ML
Interactive lesson · about 2 minutes

Step 1 Make the training data

Teach by example.

A computer sees each pixel as a number from 0 (black) to 255 (white). You provide the meaning.

Brightness32

Would you call this pixel dark or light?

1 of 12

Use ← → to browse. Press D or L to label.

Step 2 Train the model

Find the pattern.

Training turns your labels into a rule the model can use on new pixels. It tries possible cutoffs, counts the mistakes, and remembers the best.

0 · blackbrightness255 · white
0 / 60
—
What is learning?The model compares candidate rules and keeps the one that best matches your labels.
Darker than the cutoffThe model calls it dark
cutoff
At or brighter than the cutoffThe model calls it light
How does training choose the boundary?

This tiny model checks every whole-number cutoff from 0 to 255. The animation samples that search so you can watch it happen.

1 · TryPlace a candidate cutoff on the brightness scale.
2 · PredictBelow is dark; at or above is light.
3 · ScoreCount disagreements with your labels; keep the lowest score.
Ready to test 256 possible cutoffs.
Try an experiment

Call the darkest pixels “light” and the brightest pixels “dark.” Why can’t this model get a low mistake score?

Reveal the answer

The model has a built-in rule: dark belongs below the cutoff and light belongs above it. Moving one cutoff cannot reverse those sides. A more flexible model would also learn which label goes on which side. Here, the labeling pattern and the model’s rule are incompatible.

Is this how machine learning usually learns?
Yes—the basic loopChoose a model, make predictions, measure errors, and improve or select its settings.
No—the search methodThis demo can exhaustively check 256 cutoffs. Larger models have far too many possibilities. Neural networks often use gradient descent; trees and other models use different strategies.

Step 3 Use the trained model

Try a pixel it has never seen.

Training found a rule. Now give the model a new brightness value and see how it uses that rule to make a prediction.

0 · black255 · white