Scan a LEGO build with the color sensor, type in the reading, label it, and train a nearest-neighbor classifier — live, offline, on this laptop.
This laptop knows nothing about cats or dogs. Your job is to be its teacher. You'll scan LEGO builds with a color sensor and tell the computer what each one is — then test it on a build it has never seen and watch it make its own guess.
This is exactly how real machine learning works: no rules are programmed in. The machine learns only from the examples you give it. Teach it well... or teach it badly, and see what happens. 😈
How to play: ① Scan & label 4–6 cats and 4–6 dogs below → ② Scan a mystery build and press Guess → ③ Try to fool it (hint: build a cat using the dogs' colors) → ④ When you're done, open "What just happened?" at the bottom.
python sensor_bridge.py first.
Hold the sensor over the build and press Scan — or type readings manually / use the color picker.
Scan a mystery build — the model finds the 3 most similar training colors and takes a vote (k-NN, k=3).
Every scan is a point in feature space. Blue squares = cats, red squares = dogs, star = mystery build, dashed lines = its 3 nearest neighbors. Change the axes to hunt for the feature pair that best separates your cats from your dogs.
Congratulations — you just did supervised learning, the most common form of machine learning. Here's what each part of the game was, in real ML language:
The one-sentence takeaway: a machine learning model is only as good as the examples it's trained on — and it will happily learn the wrong lesson from the right data.
Bonus — the other kind of learning: here you gave the machine labels. In unsupervised learning, nobody does: the machine gets a pile of unlabeled data and must find groups on its own (try sorting a pile of LEGO with no instructions — the "rules" you invent are what an algorithm like k-means does with numbers). Supervised = learning with an answer key; unsupervised = discovering structure without one.
Questions to think about: What second measurement (besides color) would make this model harder to fool? If the model is only 2/3 sure, should a robot act on it? How many training examples would be "enough" — and how would you know?