Forty-nine fish enter the computer as two named variables, length and weight; a single photo enters as 784 unnamed pixels. First, we put the two datasets side by side and watch “finding a rule with one variable” work for the fish but pick a meaningless cell for the photos. Then, on the fish side, we check the basic tools of classification (rules, the straight lines of the perceptron and SVM, and the distances and standardization of k-NN), and move on to why photos need features that find patterns.
Forty-nine fish enter the computer as two numbers, length and weight; a single photo enters as thousands of pixel numbers. Both are numbers, so why is classifying photos so much harder?
We want to sort 49 fish brought in from the market (35 bream, 14 smelt). What we can give the computer is the length measured with a ruler and the weight measured on a scale.
| Count | Length range | Weight range | |
|---|---|---|---|
| Bream | 35 | 25.4 ~ 41.0 cm | 242 ~ 1,000 g |
| Smelt | 14 | 9.8 ~ 15.0 cm | 6.7 ~ 19.9 g |
Machine learning with fish data (decision trees, k-NN, regression, logistic regression, cross-validation, and more) is covered in detail in “Easy Machine Learning with Fish Market Data”. This episode covers only “the parts you need to move on to image classification.”
What happens if we do the same thing with photos? Even if you shrink a chihuahua or muffin photo down to a tiny 28 × 28 grayscale image, you get 784 numbers per photo. In color at 224 × 224, it’s 150,528.
There’s a bigger difference than just the amount of numbers. “Length 25.4 cm” means something on its own, but “brightness 187 in cell 412” means nothing by itself. This episode first shows that difference, the difference between variables (cells with a name and a meaning) and features (patterns that many cells make together). Then it checks the basic tools of classification (rules, lines, distances) on the fish side, and moves on to why photos need a different approach.
The fish data are real measurements (only the bream and smelt picked from the Kaggle Fish Market dataset [R1]). Bream are tall and large while smelt are slim and small, and that difference shows up directly in the numbers for length and weight. So the fish side is an easy classification, and putting it next to the photo side makes it clear “what makes photo classification hard.”
Let’s start with the conclusion, side by side. For the fish, one variable gives you a complete one-line rule; for photos, the same method picks a meaningless cell. In a photo, meaning comes not from a cell but from the arrangement of many cells, that is, from features.
| Variable | Feature | |
|---|---|---|
| Meaning | A measurement with a name and a unit | A number that summarizes a pattern made by many values together |
| Example | Length 25.4 cm, weight 242 g | “Three dark spots in a triangle,” “a pointy edge at the top” |
| Who makes it | A person decides what to measure and measures it | A filter or neural network computes or learns it from raw data (pixels) |
| Meaning of a single cell | Yes | None in a single cell (pixel) of the raw data. It lies in the arrangement |
| Methods that fit well | Rules (decision trees), linear models, k-NN | Pattern-finding models such as convolutional neural networks (CNNs) |
| Explaining | Easy: “Because it weighs more than 131 g” | Hard: you have to look separately at what the learned filters respond to |
In machine learning, both are often just called “features.” To make the difference clear, this series calls measurements that people have named variables and patterns found in the arrangement of raw data features.
On the left (top on mobile) are the fish; on the right (bottom) are the photos. First, look for a rule of the form “if one variable > threshold, then this class” in both datasets. For the fish, that’s all you need, but for the photos, the rule picks a meaningless cell. So for photos, we look at patterns in feature maps made with filters. Rules and patterns are found on 80 “training” photos and checked on 80 “new photos” that weren’t used for training.
Each variable has a name and a meaning, so a single rule that people can read does the job.
① In the same way, look for a “one pixel > threshold” rule across all 784 cells.
② Make feature maps with filters, then summarize the pattern over each whole map.
Dot and fish colors: ● bream · chihuahua ● smelt · muffin. The two filters in ② on the right (dark-area finder, edge finder) were picked by a person for this comparison. A CNN learns dozens to hundreds of such filters from data and combines them (4-2 · 4-3). The “new photos” were made from the same 12 images by shifting them and changing their brightness differently from the training set, so this test is easier than one with completely different photos. With real photos, it’s hard to reach 100% with just two patterns.
The cells of the fish data are variables with a name and a meaning. The single variable “length” captures the difference between bream and smelt, so the one-line rule “if length > threshold, it’s a bream” gets all 49 fish right. It’s a rule people can read and explain, and it’s the kind of thing rule-based models like decision trees do well. It also works because a person chose well “what to measure.”
The cells of a photo (pixels) are formally variables too, but they have neither a name nor a meaning. If you look for a rule the same way, the computer picks whichever of the 784 cells happened to fit well, often a background cell near the border, and performance drops on photos it hasn’t seen before. In a photo, meaning comes not from a single cell but from patterns that many cells make together (how many dark spots, where, and in what shape). So if you make feature maps with filters and summarize the pattern over each whole map, it gets new photos right too.
To sum up, both have this in common: they “decide based on features.” What differs is whether the features were named and prepared by people (variables → rules), or have to be found in the arrangement of many cells (pixels → patterns). Tabular data can also use non-rule models like logistic regression, and rules can also be applied to photo features, so think of this contrast as a tendency: “what works well on which kind of data.”
So should we just use all 784 cells? More cells give you more ways to split the data, but since most of the cells are meaningless, the problem doesn’t go away. In 4-2 we look at filters that find patterns, and in 4-3 we view this problem through the lens of “splitting with a plane.”
Click “Find rule automatically” for the fish on the left and “Find pixel rule automatically” for the photos on the right. The fish rule gets all 49 fish right, and people can read it. The photo rule picks a background cell in a corner of the photo out of the 784 cells, and its accuracy drops on photos it hasn’t seen before. As in ② on the right, you have to make feature maps with filters and summarize the patterns before the photos separate. This contrast is the starting point for the whole series.
Each row is one sample, the number columns are features, and the answer column is the target. The fish table and the photo table differ only in the number of columns and what a single column means.
The data a classification model learns from is always a table of the same shape. Each row is one sample, and each row has several number columns called features and one target (label, the correct answer) column. For fish classification, each row is one fish, the features are two columns (length and weight), and the target is “bream” or “smelt.” Photo classification is exactly the same. Each row is one photo, the features are the photo’s pixel numbers laid out in a single row (more on this in 4-2), and the target is “chihuahua” or “muffin.”
In plain termsIt’s like a health checkup chart. Each person is one row, height, weight, and blood pressure are the feature columns, and “needs a follow-up exam or not” at the very end is the target column. The fish table is a short checkup chart with 2 items, and the photo table is a very long one with 784 items. The difference is whether each item has a name and a meaning. “Length 25.4 cm” means something on its own, but “brightness 187 in cell 412” means nothing by itself.
On the left are 6 of the 49 fish; on the right are 6 of the 80 chihuahua and muffin photos. The photos were shrunk to 28 × 28 grayscale and then flattened into a single row. Click a row in the right-hand table to see below how that photo becomes a single row.
Fish data: length and weight of 35 bream and 14 smelt from the Kaggle Fish Market dataset. The values were taken as is from the example code (MIT License) of Haesun Park’s Hands-On Machine Learning & Deep Learning (혼자 공부하는 머신러닝+딥러닝). Photo data: the 12 images from episode 4-4 (6 chihuahuas, 6 muffins) were shrunk to 28 × 28, and for each image, the position was shifted by up to ±4 cells and the brightness changed to 70–130% to make 40 photos per class.
Q1. In the photo classification table, what is the target (label)?
Q2. If you flatten a 32 × 32 color photo into a single row, how many features do you get?
Q3. For fish, a rule can be built from a single variable. What is the main reason a rule built from a single pixel doesn’t work well on new photos?
The target is the answer to be predicted, and having people attach those answers is called labeling. Click a row in the photo table and you’ll see the 28 × 28 matrix joined row by row, starting from the first, into a single row of 784 values (flatten). The format becomes the same as the fish table, but each column loses its name and meaning.
When variables have meaning, the boundary is simple. We look at what line the perceptron, which moves the line every time it’s wrong, and SVM, which builds the widest road, draw on the same fish.
Each dot is one fish. The purple line is the current boundary, and the upper right of the line is “bream.” The perceptron looks at the fish one at a time and moves the line only when it is wrong. A red circle marks the fish it just got wrong; a white circle marks a fish it got right.
There are countless straight lines that separate the two groups. SVM picks the one with the widest empty road (margin) between the two groups. The solid purple line is the boundary, and the dotted lines are the two edges of the road. Check the box to compare it with the line where the perceptron stopped (green dotted line).
The perceptron and a linear SVM draw the same shape of boundary (one straight line, w·z + b = 0). The perceptron stops as soon as it gets everything right, so it can end up with a line that hugs one group, while SVM picks the line farthest from both groups (maximum margin). In Code 1, the SVM’s margin width was 1.233 in standardized units, and the support vectors that set the boundary were two fish: the largest smelt (15.0cm, 19.9g) and the smallest bream (25.4cm, 242g).
Remember the order, too. The perceptron (1958) came first and SVM (1990s) came later [R3] [R4]. Both draw a single straight line in the original coordinates, so they are enough for the fish table, where each column has meaning, but they get stuck in pixel coordinates (4-3).
Machine learning with fish data (decision trees, k-NN, regression, logistic regression, cross-validation, and more) is covered in detail in “Easy Machine Learning with Fish Market Data”. This episode covers only “the parts you need to move on to image classification.”
The perceptron multiplies length and weight by their weights, adds them up, and answers bream if the sum is greater than 0. Learning is just repeating “move the line a little toward the fish it got wrong.” Turn on the checkbox in the SVM plot to overlay the perceptron’s final line on the SVM line. This weighted sum (w·x + b) comes back unchanged in the convolution of 4-2 and the neural networks of 4-3.
Is a new fish (25cm, 150g) a bream? When you ask the nearest neighbors, the answer flips depending on how you measure “near.”
The triangle is a newly caught fish (starting values: length 25cm, weight 150g). The k-nearest neighbors method takes a majority vote among the answers of the 5 closest fish. Switch between “Original units” and “Standardization” and watch how the neighbors change.
If you measure distance in the original units, a 10cm difference in length counts the same as a 10g difference in weight. But weights differ by hundreds of grams, so weight decides almost all of the distance. That’s why a new fish 25cm long still comes out “close” to the smelt (20g or less) because of its 150g weight, and 4 of its 5 neighbors turn out to be smelt. After standardization, both features are on the same scale, and all 5 neighbors become bream (the same as the result of Code 1).
A rule (Section 3) looks at only one variable, so units don’t affect it. Methods like the perceptron, SVM, and k-NN that mix several features to compute a distance or weighted sum need their units matched. In photos, every cell is 0–255, so this problem is small, but a different problem shows up instead (Section 7).
k-nearest neighbors (k-NN) takes a majority vote among the answers of the k samples closest to the new sample [R5]. It’s simple, but “distance” is everything, so when a variable with large numbers, like weight (g), takes over the distance, it picks the wrong neighbors. Pixels in a photo are all 0–255, so the unit problem is small, but there is a bigger problem instead: “the difference between numbers in the same position” doesn’t reflect meaning (4-2 Section 3).
How far can you get using the cells of a photo like the variables of a fish? The results split between pairs with different shapes and pairs that look alike.
| Digit pair | Pixel chosen by the rule | Single-pixel rule (test) | 64-cell weighted sum (test) |
|---|---|---|---|
| 0 vs 1 | (row 5, col 5) | 98.3% | 100.0% |
| 3 vs 8 | (row 6, col 4) | 86.0% | 98.3% |
| 4 vs 9 | (row 5, col 2) | 93.9% | 98.3% |
We treated 8 × 8 handwritten digits as a 64-column table and applied the “one variable > threshold” rule we used for the fish. 0 and 1, which look very different, are almost completely separated by a single center pixel (if the center is empty, it’s a 0). But for a pair that looks alike, such as 3 and 8, the single-pixel rule reaches only 86.0%, and you need a weighted sum of all 64 cells to reach 98.3%.
The more alike the shapes are, the more you need to look at the shape that many cells make together, not at a single cell. Handwritten digits are small photos with neatly aligned positions, so a weighted sum alone works well, but in real photos where position, lighting, and background vary, even a weighted sum gets stuck (4-2 Section 3, 4-3 Section 2). That’s why photo classification needs a step that finds patterns: feature extraction.
To sum up, for table data whose variables have meaning, simple tools like rules, lines, and distances are enough. In photos, a single cell has no meaning, so you need filters that find patterns across neighboring cells and layers that stack those patterns into shapes. 4-2 covers how a photo becomes a matrix of numbers and how filters work, 4-3 covers why we stack layers, and 4-4 covers the difficulties that still remain.
Both code samples use only libraries that come preinstalled in Colab and built-in data. Click “Download notebook (.ipynb)” and open it in Colab with File → Upload notebook, or copy the code and paste it into a new notebook cell.
Computes a one-line decision tree, a perceptron and a linear SVM in standardized coordinates, and the k-NN prediction for a new fish (25cm, 150g) before and after standardization. To use your own data, replace the four lists at the top with your own measurements.
Treats 8 × 8 handwritten digits as a 64-column table and compares a single-pixel rule with a 64-cell weighted sum (logistic regression) on 0 vs 1, 3 vs 8, and 4 vs 9. To use your own data, change the digit pair in compare(a, b).
These are prompts to paste into an AI assistant such as ChatGPT, Qwen, or Claude. Click “Copy” and the code you selected is attached after the prompt. Replace the text inside 〔 〕 with your own situation.
An AI’s answer is only a starting point. Always check any papers, figures, or library functions it suggests against the originals and the official documentation. If you used AI help for a competition entry or a paper, disclose that you did and to what extent, following the rules of the organizers or the journal.
This is the same dictionary as the yellow dotted underlines in the text. The same terms are used throughout the series. Click a section name to jump to where the term first appears.
Analogies are a first step toward understanding, but they can also plant misunderstandings. Analogies to the human eye and brain are marked by strength. Direct There is evidence that it actually does the same thing · Partial Only some properties are similar · None No known counterpart
| Concept | Everyday analogy | Human eye/brain analogy | Where the analogy breaks down |
|---|---|---|---|
| Decision tree | Twenty Questions | None | A real decision tree picks the threshold for each question by calculating it from the data. It doesn’t come up with “plausible questions” the way a person does |
| Perceptron | A mistake notebook where you review only the problems you got wrong | Partial It came from the idea that a nerve cell collects inputs and sends a signal once they cross a threshold | Real nerve cells handle electrical signals that change over time, and their learning rules are far more complex |
| SVM margin | Building the widest possible road between two sides | None | The road width is measured in “standardized units.” Change the units and the position of the widest road changes too |
| k-NN | Asking the five nearest neighbors after moving into a new neighborhood | None | Neighbors are measured not by “how many meters away” but by “how many grams and centimeters different,” so if you don’t match the scales, you mistake a far house for a near one |
| Standardization | Comparing height and weight by converting them to “roughly what rank in class” | None | A rank keeps only the order, but standardization keeps how far a value is from the mean (the spacing) |
E-1 About the Author · E-2 Academic References · E-3 Figure and Data Sources
A guide for instructors, on-the-job training (OJT) leads, and tutors. Times are estimates, so adjust them to your actual class.
| Audience | College students and working professionals new to machine learning: people who can handle Excel tables but have never worked with a model |
|---|---|
| Prerequisites | Mean and standard deviation, and the equation of a line on the coordinate plane. Reading the perceptron in 3-2 helps |
| Learning Goals | ① Explain the difference between variables and features using the fish and photo examples ② Describe data in terms of samples, features, and targets, and explain how rules, the perceptron, SVM, and k-NN differ in how they set a boundary ③ Explain when standardization is needed and why a single pixel shouldn’t be used like a variable |
| Estimated Time | Reading 35–45 min · hands-on demo 20 min · Colab practice 25 min (Code 1: 15 min, Code 2: 10 min) |
Intro 5 min (Section 1) → Section 2 variables vs features 15 min → Section 3 table structure 5 min → Section 4 perceptron 10 min → Section 5 k-NN 5 min → Section 6 bridging 5 min → Check Questions 5 min.
Redraw Sections 1 and 2 as your company’s data tables 20 min → compare the rule in Section 3 with SVM in Section 5 20 min → find the standardization trap in Section 6 (check the units in your data) 20 min → run Code 1 on your data 30 min.
Beginners: Sections 1, 2, 3, and 6 only. Intermediate learners: work through the update formula in Section 4 once by hand, and explain why Code 1’s SVM has two support vectors.
| Section | Questions to pause and ask | Interaction tips |
|---|---|---|
| 1 Problem | “What’s the difference between a length of 25.4cm and a value of 187 in cell 412?” | Point to the fish table and the number of values in a photo side by side |
| 2 Variables vs features | “Does the cell chosen by the pixel rule have anything to do with chihuahuas?” | Press “Auto find” on each side in turn |
| 3 Features & targets | “Which column in this table is the answer?” | Click a photo row to see the flattened row |
| 4 Rules and lines | “Why doesn’t the line move when it sees a fish it got right?” | Use “One at a time” to stop at a red circle (wrong), and overlay the perceptron line on the SVM plot |
| 5 Standardization | “Why are the new fish’s neighbors smelt?” | Switch from original units to standardization, and move the weight slider too |
| 6 Pixels as variables? | “Why does it work for 0 and 1 but not for 3 and 8?” | Compare the two columns of the Code 2 results table |
| Misconception | Correct explanation | Scene to show |
|---|---|---|
| The perceptron was invented because SVM didn’t work | It’s the other way around. SVM (1990s) came after the perceptron (1958) | Section 5 explanation |
| Anything that finds weights is a perceptron | Linear SVM and logistic regression also find weights. The difference is the criterion for choosing the boundary | Comparing the formulas in Sections 4 and 5 |
| If you have enough features, you don’t need standardization | For methods that use distances or weighted sums, different units can flip the result | The (25cm, 150g) fish in Section 6 |
| Rule-based models are outdated | For table data whose features have meaning, they are still strong today and easy to explain | The one-line rule in Section 3 |
| Photos are tables too, so the same methods work | The format is the same, but a single cell has no meaning, so you need a step that finds patterns | Section 7 and Code 2 |
49 samples (rows), 2 features (length and weight), and the target is a single column: bream 1 / smelt 0.
w ← w + 0.5 × (+1) × (0.2, −0.1) = w + (0.1, −0.05). b increases by 0.5.
Yes. Both are straight lines where w·z + b = 0. SVM picks the one with the widest margin.
Because the weight difference decides almost all of the distance. Numerically, 150g is closer to the smelt (20g or less) than to the bream (242g or more).
Only the threshold number becomes 10 times larger; the fish it gets right stay the same. A rule that looks at only one variable isn’t affected by units.
In Code 1, remove StandardScaler, train the SVM, see how the boundary and support vectors change, and explain it in two sentences, connecting it to Section 6.
In Code 2, increase the decision tree’s depth to 1, 3, and 10, make a table of the train and test accuracy for 3 vs 8, and interpret how the gap between train and test changes as the tree gets deeper.
| Beginners | You can skip the formulas in Sections 4 and 5 without losing the thread. Just make sure to do the hands-on activities in Sections 3 and 6 |
|---|---|
| Advanced | Have learners compare logistic regression in the same kind of table as Sections 4 and 5, and present the difference between classifiers that output probabilities and classifiers that output only a boundary |
| Learn more | Easy Machine Learning with Fish Market Data (complete machine learning with the fish data) · Sangsun Ahn, “Data Science for Business” course materials |
| Instructor materials | Grading criteria for the Check Questions and sample answers to the assignments are on the answer page for educators (4-1) |
You’ve read the “4-1 Bream vs Smelt” episode all the way through. The lab crew will each sum it up in a few words.