In 1.1.1 your model learned from raw text and predicted a next word. This activity uses a different kind of learning. You show the computer many examples that already have the right answer attached, such as a photo labeled "daisy" or "rose." The computer adjusts itself until it can give the right label to examples it hasn't seen. Learning from examples with answers attached is called supervised learning, and the answers are called labels.
When the answer is a category (daisy or rose, spam or not spam, diseased or healthy) the task is classification. When the answer is a number (a house price, tomorrow's temperature) the task is regression. Both are "predicting," but they predict different kinds of things. Most of this page is about classification, and the section on how models learn shows regression at the end.
You see a flower. The computer gets a grid of numbers. A digital picture is made of tiny squares called pixels. In a black-and-white picture each pixel is a single number for how bright it is, from 0 (black) to 255 (white). In a color picture each pixel is three numbers: how much red, green, and blue.
To a computer this picture is 36 numbers: 0 for black through 255 for white. Right now 8 pixels are 0 and 28 are 255.
A photo from a phone camera has millions of pixels, so one photo is millions of numbers. Nothing in those numbers says "petal" or "stem." The model has to discover which patterns of numbers tend to go with which label.
A spreadsheet with a row per student and a column per quiz score is structured data: it has rows, columns, and meaning attached to each position. Photos, audio, and free-form text are unstructured data: just raw values with no labeled columns. Most of the information in the world is unstructured, and learning from it is a big reason modern AI models need so much data and computing power.
Picture a student who memorizes the answer key to a practice quiz. Ask the exact same questions and they score 100%. Change the questions and the score collapses. A model can do the same thing. A model's score on the very images it trained on mostly shows that it can fit those images. It doesn't show that it will cope with new ones.
So before training, set some labeled images aside. These test images are never used to train. After training, run the model on them and compare its answers to the real labels. The rest are the training images. This is called a train/test split.
With 12 test images, one wrong answer moves your score by 8.3 percentage points. A reasonable balance for a set this small: enough to learn from, enough to test with.
Even a good test has limits. It only tells you how the model does on images like the test images. If the test photos were all taken in a classroom and the model will be used outdoors, the score may not carry over. A test is only as good as its match to real use.
"How many did it get right?" is a start, but the more useful question is "how was it wrong?" A confusion matrix is a table that sorts every test result by what the answer really was and what the model said. For a yes/no task, pick one answer as the positive class (the thing you're looking for: diseased, spam, peanuts). Then every result lands in one of four boxes:
From the four boxes you can calculate three common scores:
Accuracy is how often the model was right overall. Precision asks: when the model says "positive," how often is it right? Recall asks: of the things that really are positive, how many did the model find?
A farm app is tested on 100 leaf photos it never trained on. 20 leaves are really diseased. The app caught 16 of them, missed 4, wrongly flagged 8 healthy leaves, and correctly cleared 72 healthy leaves.
The leaf-photo example from this page.
A false negative and a false positive are different mistakes with different prices. For a peanut-allergy scanner, a miss can put someone in the hospital; a false alarm only sets aside a safe snack. For a school's spam filter, a false alarm can bury an important message; a miss is just one more junk email. Tuning a model to make fewer of one mistake usually means more of the other, so people have to decide the trade-off. That decision is a human one, and it should be made on purpose.
Suppose only 5 out of every 100 leaves are diseased. A "model" that never looks at the photo and always answers "healthy" is right 95% of the time. It sounds excellent. It also catches zero diseased leaves. When one class is rare, accuracy can hide a useless model. Recall and the confusion matrix expose it right away.
The same thing happens inside training. In the flower lab you trained with 50 daisy images and only 10 rose images. A lopsided set pushes the model toward the common class. On a test set with the same mix, a model that always said "daisy" would score 83.3% without learning anything about roses.
Roses are 16.7% of the images. A model that ignores the picture and says "daisy" every time would be right 83.3% of the time on a test set with the same mix. So a score in that range doesn't yet show the model has learned anything about roses.
Teachable Machine hides the learning inside a progress bar. The idea underneath is simple enough to try by hand. A classifier looks for a decision boundary: a line (or, with more features, a surface) that separates one class from the other. It starts with a guess. It counts how badly that guess does. It adjusts the line and tries again.
The measure of "how badly" is called loss. A big loss means the line is doing a poor job; a loss near zero means it's doing well. Learning is the process of nudging the line's numbers (here, its slope and its shift) so the loss goes down. Those adjustable numbers are the model's weights. Your dice models in 1.1.1 had a few counts; real models have billions of weights, but they are tuned by this same guess-measure-adjust loop.
Best any straight line can do on this data: 1 mistake (that odd daisy looks like a rose).
Try it two ways. First, drag the sliders yourself and watch the mistake count and the loss. Then reset and press Let it train: the computer tries small random changes and keeps any change that lowers the loss. Notice that it stops improving before it reaches zero mistakes. The odd daisy sits in rose territory, and no straight line can fix that. Real data is full of cases like this, and engineers have to decide whether to use a more flexible model, fix a wrong label, or accept the error.
When the answer is a number, the model draws a best-fit line through the data instead of a boundary between classes. The loss is how far each prediction is from the real value. A common version is mean squared error: square each miss (so big misses count a lot and the sign doesn't matter), then take the average. For example, if a model predicts 3, 5, and 8 when the real values are 4, 5, and 6, the misses are −1, 0, and 2. Squared they are 1, 0, and 4, and the average is (1 + 0 + 4) ÷ 3 ≈ 1.67. Training tries line after line until that number is as small as it can get.
A model learns whatever its training examples teach it, including their gaps. If some people or situations are scarce in the data, the model has had little chance to learn them. An overall accuracy number averages everyone together, so it can look fine while the model fails a particular group.
In 2018, researchers Joy Buolamwini and Timnit Gebru tested three commercial systems that guess a person's gender from a face photo. They built a more balanced test set and reported results by group instead of one overall score. The systems were close to perfect for lighter-skinned men (error rates under 1%) and much worse for darker-skinned women, with error rates as high as about 35% for the worst system. They also pointed out that benchmark datasets used at the time contained mostly lighter-skinned faces. The companies involved later reported making improvements.
The lesson is about method, not just that one study. Report results by group, not only overall, and build test sets that include the people the system will actually meet. Face-recognition errors have had real consequences: in the United States, several people have been wrongly arrested after a face-recognition match that turned out to be wrong.