Week 3 · Lesson 1 · 45-55 minutes
How an Image Classifier Works
Follow a photo from pixels to a label, and learn how an image classifier turns visual features into a prediction with a confidence score.
- Materials
- This lesson in a web browser · Paper and pencil, or a notes app · The built-in labeled image sets shown in the lesson
- This lesson
- In progress
Auto-saves on this device
What you'll be able to do
- Explain that an image is made of pixels a computer reads as numbers.
- Describe how a classifier uses visual features to make a prediction.
- Read a confidence score and say what it does and does not mean.
- Trace an image through a classifier from input to labeled output.
Think about it
You show a photo app a picture and it instantly says 'cat, 96% sure'. It has never seen this exact photo before. How could a computer, which only sees numbers, decide it is a cat?
Keep your first guess in mind — you will check it after you see how pixels become a prediction.
Make a prediction
Predict: when a classifier looks at a photo, do you think it recognizes the whole 'cat' at once, or does it build its answer from smaller patterns like edges and shapes?
Vocabulary
See the full course vocabulary- Pixel
- One tiny dot in an image. A picture is a grid of pixels, and the computer stores each one as numbers for its color and brightness.
- Visual feature
- A pattern in a picture the classifier pays attention to, such as edges, colors, shapes, or textures.
- Classification
- Sorting something into one of a set of named groups, called categories or classes.
- Prediction
- The category the classifier chooses as its best guess for an input image.
- Confidence
- A number, often shown as a percent, for how sure the classifier is about its prediction. Higher means more sure, but not always more correct.
A picture is a grid of pixels, and pixels are numbers
A computer cannot 'see' a photo the way you do. To a computer, an image is a grid of tiny dots called pixels, and each pixel is stored as numbers that describe its color and brightness. A small photo can have hundreds of thousands of pixels.
So the very first thing a classifier receives is not a 'cat' — it is a big grid of numbers. Everything the classifier decides has to be built up from those numbers.
- A black-and-white pixel might be stored as one number from 0 (black) to 255 (white).
- A color pixel is often stored as three numbers: how much red, green, and blue it has.
- A 100 by 100 photo is 10,000 pixels — a lot of numbers for one small picture.
From pixels to visual features
Working with raw pixels alone is hard, so a classifier looks for visual features: useful patterns like edges, corners, colors, textures, and shapes. Pointy triangular shapes near the top might be a feature that often shows up with cats (ears).
The classifier learned which features matter by studying many labeled examples in earlier training. It was not told 'cats have pointy ears' as a rule — it found patterns like that from the examples, the same learning idea from earlier weeks.
- Edges where a dark area meets a light area
- Round shapes, which might be eyes or wheels
- Textures like fur, scales, or smooth metal
Prediction and confidence
After adding up the visual features, the classifier makes a prediction: it picks the category that best matches, like 'cat' or 'dog'. Along with the prediction it usually reports a confidence — a number for how sure it is, often shown as a percent.
Confidence is useful but tricky. A high confidence means the features matched one category strongly, not that the answer is definitely right. A classifier can be confidently wrong, which is exactly the kind of mistake you will study this week.
- 'Dog, 91%': the features matched dog much more than any other category.
- 'Cat 55%, dog 45%': the classifier is unsure — the picture had features of both.
- A confident 98% can still be wrong if the photo is unusual.
Worked example
Following one photo from pixels to a label
- Input: a photo of a cat arrives as a grid of pixels — just numbers for color and brightness.
- Find features: the classifier detects edges, then two pointy shapes near the top, round eye shapes, and a fur texture.
- Score each category: those features match 'cat' strongly and 'dog' only a little.
- Predict with confidence: it outputs 'cat' with 96% confidence because cat features scored much higher than the others.
- Output: the label 'cat' and the confidence are shown to you. The whole answer was built from pixels, not from the computer truly 'seeing' a cat.
Takeaway: A classifier turns pixels into visual features, scores each category from those features, and reports the best match as a prediction with a confidence.
A four-step flow. Step 1: Input image, drawn as a grid of pixels (numbers). Step 2: Find visual features — edges, shapes, colors, textures. Step 3: Score each category from the features — for example cat 96, dog 3, rabbit 1. Step 4: Output the top category as the prediction with its confidence: 'cat, 96%'. The arrow makes clear the label is built up from pixels, not seen directly.
Every prediction is built from pixels, through features, into a scored guess.
Values shown in % confidence.
A bar chart of the classifier's confidence for each category on a single cat photo, in percent. Cat is by far the tallest bar at 96 percent, dog is 3 percent, and rabbit is 1 percent. The tallest bar is the prediction; its height is the confidence. The bars add up to about 100 percent because the classifier is splitting its certainty across the categories.
The tallest bar is the prediction; its height is the confidence.
Activity
Classifier Walkthrough
Follow a built-in picture from pixels to a labeled prediction, and see how confidence compares the categories without guaranteeing the answer.
- Pick a picture. See it the way a computer does — a grid of numbered pixels.
- Look at the visual features the model measured, then its prediction and confidence.
- Notice that confidence compares the categories; it is not a promise the answer is right.
2 · A picture is a grid of pixels
A solid circle, smaller size, centered. The computer stores this 16×16 grid as 256 numbers — one brightness value per pixel.
3 · Features measured from the pixels
- ink coverage18%
- fill inside its box81%
- top-left corner18%
- left-right symmetry100%
- edge (outline) amount38%
4 · Prediction and confidence
The closest training pictures were: Circle (91% similar), Square (86% similar), Circle (80% similar). The model added up the similarities and chose Circle, giving it 66% confidence. Confidence compares the categories to each other — it is not a promise the answer is right.
Confidence is not certainty
A square rotated 45 degrees, so it looks like a diamond.
The real answer is Square, but the model predicts Circle with 69% confidence. A model can be confident and still wrong — high confidence only means the categories looked lopsided to the model, not that it is correct.
Optional: try your own picture
Everything above works with the built-in pictures — this is an extra. If you upload a picture, it is shrunk to a 16×16 grid and classified entirely on your device. It is never saved and never sent to any service. Draw a big circle, triangle, or square on white paper for the best result.
Check your understanding
Answer these to check that you understand how an image classifier turns pixels into a prediction.
Question 1. What does an image classifier actually receive as its input?
Question 2. Put the steps of image classification in order, from receiving the photo to showing the answer.
- 1.Receive the image as a grid of pixels
- 2.Find visual features like edges, shapes, and textures
- 3.Score how well the features match each category
- 4.Output the top category as the prediction with its confidence
Question 3. Decide if the statement is true or false.
A prediction with 98% confidence is guaranteed to be correct.
0 of 3 answered
Try it yourself
Be the classifier
Pick a simple object you can picture (an apple, a bicycle, a house) and describe how a classifier could tell it apart from a close cousin using visual features.
- Choose your object and one similar object it could be confused with (apple vs. tomato, bicycle vs. motorcycle).
- List three visual features that would push a prediction toward your object.
- List one feature that both objects share, which could make the classifier unsure.
Success looks like
- A pair of similar objects is chosen.
- Three distinguishing visual features are listed.
- One shared feature that could lower confidence is named.
Reflection
Saved on this device as you type
Please don't include private information. Your answers are saved only in this browser and are never sent anywhere.
Recap
An image classifier turns a grid of pixels into visual features, scores each category, and outputs the best match as a prediction with a confidence.
- To a computer, an image is a grid of pixels stored as numbers.
- Classifiers work from visual features like edges, shapes, colors, and textures.
- A prediction comes with a confidence, and high confidence does not guarantee a correct answer.
Grades 7–8 extension
Why confidence can fool you
Confidence tells you how strongly the features matched a category, not how correct the answer is. A classifier trained only on clear daytime photos might be 95% confident and wrong on a blurry night photo, because the unusual pixels still happened to match one category best.
Describe a situation where you would want a system to say 'I am not sure' instead of giving a confident answer. Why might a designer set a rule like 'if confidence is below 60%, ask a human'?
Finish this lesson
- Attempt the knowledge check — not done
- Save a reflection (recommended) — not done
Attempt the knowledge check to finish this lesson.