Bream vs Smelt — Variables and Features: What’s the Difference?

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.

2 vs 784Number of fish variables vs number of pixels in a 28 × 28 photo
130.95gWeight threshold found by the decision tree
92.5 → 81.3%Photo pixel rule: training → new photos
1958 · 1995The perceptron and SVM papers [R3]
86 vs 98%Handwritten 3 vs 8: one-pixel rule vs 64-cell weighted sum
2Code samples that run right away in Colab
1Problem

Numbers in a Table vs Numbers in a Photo — What’s the Difference?

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?

1Two Fish and Two Numbers
The shapes of bream and smeltA drawing of a tall, round bream and a slim, long smelt at the same scale. The bream is about 30 cm long, the smelt about 12 cm Bream · about 30 cm · about 500 g Smelt · about 12 cm · about 10 g Drawn to the same scale (roughly): 2.5× difference in length, about 50× in weight

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.

CountLength rangeWeight range
Bream3525.4 ~ 41.0 cm242 ~ 1,000 g
Smelt149.8 ~ 15.0 cm6.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.”

2How Many Numbers Is a Photo?

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.

Explained for Beginners

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.”

2Variables vs features

Variables vs Features — Named Cells and Unnamed Cells

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.

1Variables and Features · Compared by the Same Criteria
VariableFeature
MeaningA measurement with a name and a unitA number that summarizes a pattern made by many values together
ExampleLength 25.4 cm, weight 242 g“Three dark spots in a triangle,” “a pointy edge at the top”
Who makes itA person decides what to measure and measures itA filter or neural network computes or learns it from raw data (pixels)
Meaning of a single cellYesNone in a single cell (pixel) of the raw data. It lies in the arrangement
Methods that fit wellRules (decision trees), linear models, k-NNPattern-finding models such as convolutional neural networks (CNNs)
ExplainingEasy: “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.

2Side-by-Side Hands-on · Finding Rules with Variables vs Finding Patterns with 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.

Fish · variables → rule

Each variable has a name and a meaning, so a single rule that people can read does the job.

Variable
Photos · pixels → patterns

① In the same way, look for a “one pixel > threshold” rule across all 784 cells.

Press the button to find the pixel rule that gets the most right.

② Make feature maps with filters, then summarize the pattern over each whole map.

Example
Photo
Dark-area map
Top-edge 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.

3Interpretation

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.”

Explained for Beginners

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.

3Features & targets

The Structure of a Table — Samples, Features, Targets

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.

1Definition

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.”

Fish table2 feature columns (length, weight)
Photo table (grayscale 28 × 28)784 feature columns
TargetOne column of 0 or 1 in both

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.

2Formula
D = { (x⁽¹⁾, y⁽¹⁾), (x⁽²⁾, y⁽²⁾), …, (x⁽ⁿ⁾, y⁽ⁿ⁾) },   x⁽ⁱ⁾ ∈ ℝᵈ,   y⁽ⁱ⁾ ∈ {0, 1}
Fish: x = (length, weight),  d = 2   |   Photo: x = (X[1,1], X[1,2], …, X[28,28]),  d = 784Join the rows of the photo’s matrix one after another, starting from the first, to make a single row (flatten). For color 56 × 56, d = 9,408; for color 224 × 224, d = 150,528.
n
Number of samples (rows in the table). 49 fish; 80 photos in this section
d
Number of features (columns in the table). The dimension of the input vector
x⁽ⁱ⁾
Feature vector of the i-th sample
y⁽ⁱ⁾
Target of the i-th sample. Set bream · chihuahua = 1, smelt · muffin = 0
Reading the Formula Piece by Piece
  1. (x, y) pairThe question and its answer are kept together as a bundle. The answer has to be attached so the model can measure how wrong it is and correct itself (supervised learning). Attaching the answers is called labeling.
  2. ℝᵈThe d-dimensional space formed by d features. One sample is one point in this space. A fish is a point on a plane; a photo is a point in 784-dimensional space.
  3. {0, 1}Turns the name tags into numbers. Which one is 1 is just a convention and has no effect on the result.
Try It with NumbersOne bream: x = (25.4, 242.0), y = 1  ·  One smelt: x = (9.8, 6.7), y = 0
One chihuahua photo: x = (x₁, x₂, …, x₇₈₄) = (133, 147, 148, …) 784 values, y = 1
The tables have the same shape; only the number of columns differs: 2 vs 784.
3The Two Datasets Side by Side as Tables

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.

✓Check Question

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?

Explained for Beginners

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.

4Rules and lines

For Fish, One Rule or One Line Is Enough — The Perceptron and SVM

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.

1Animated Hands-on · How the Perceptron Fixes Its Line

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.

2Formula · The Perceptron’s Learning Rule
Prediction:   ŷ = 1  if  w₁z₁ + w₂z₂ + b > 0
Only when wrong:   w ← w + η · t · z,   b ← b + η · t   (t = +1 bream, −1 smelt)η (eta) is how far the line moves at a time (the learning rate). This hands-on uses η = 0.5. z is the standardized length and weight (Section 6).
w₁, w₂
The weights for length and weight. They set the line’s slope
b
The bias. It sets the line’s position
t
The sign of the answer. +1 if it was a bream but was called a smelt, −1 the other way around
Why this fix works
  1. w + η·t·zIf it missed a bream (t = +1), it turns w a little toward that fish’s direction z. Then the next time it sees the same fish, w·z is larger and the fish tips over to the “bream” side.
  2. When it stopsIt stops when it gets through one full pass (49 fish) without a single mistake. It has been proven that, as long as the two groups can be separated by one straight line, it will always stop eventually (the perceptron convergence theorem).
3Hands-on · The Boundary That Builds the Widest Road

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).

4Interpretation · How the Perceptron and SVM Relate

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.”

Explained for Beginners

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.

5Standardization

Different Units, Wrong Distances — k-NN and Standardization

Is a new fish (25cm, 150g) a bream? When you ask the nearest neighbors, the answer flips depending on how you measure “near.”

1Hands-on · Is the New Fish a Bream or a Smelt?

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.

Units for measuring distance
2Formula · Standardization
z = (x − mean) / standard deviation
Length: mean 27.06cm, standard deviation 10.14cm  |  Weight: mean 444.5g, standard deviation 324.8g

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).

Explained for Beginners

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).

6Pixels as variables?

Can a Single Pixel Be a Variable? — On to the Next Episode

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.

1Results of Colab Code 2 · Pixel Rules for Handwritten Digits
Digit pairPixel chosen by the ruleSingle-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.

Explained for Beginners

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.

Colab Code — Run This Page Yourself

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.

Code 1 · Comparing Rules, the Perceptron, SVM, and k-NN on Table DataLinked to Sections 4 and 5 · numpy, scikit-learn · under 1 second on CPU

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.

Output (run on 2026-10-04, numpy 2.4 · scikit-learn 1.8 · CPU). The calculation uses almost no randomness, so you get the same result whenever you run it.
Code 2 · Are Pixels Variables Too? — Comparing Rules and Weighted Sums on Handwritten DigitsLinked to Section 6 · numpy, scikit-learn (built-in data) · a few seconds on CPU

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).

Output (run on 2026-10-04, scikit-learn 1.8 · CPU). Changing the random_state of the data split changes the numbers slightly.

AI Prompts to Try — Use This Code as a Starting Point

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.

Code to attach

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.

Glossary

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 — and Where the Analogy Breaks Down

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

ConceptEveryday analogyHuman eye/brain analogyWhere the analogy breaks down
Decision treeTwenty QuestionsNoneA 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
PerceptronA mistake notebook where you review only the problems you got wrongPartial It came from the idea that a nerve cell collects inputs and sends a signal once they cross a thresholdReal nerve cells handle electrical signals that change over time, and their learning rules are far more complex
SVM marginBuilding the widest possible road between two sidesNoneThe road width is measured in “standardized units.” Change the units and the position of the widest road changes too
k-NNAsking the five nearest neighbors after moving into a new neighborhoodNoneNeighbors 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
StandardizationComparing height and weight by converting them to “roughly what rank in class”NoneA rank keeps only the order, but standardization keeps how far a value is from the mean (the spacing)

About the Author and References

E-1 About the Author · E-2 Academic References · E-3 Figure and Data Sources

E-1 About the Author

Sangsun Ahn (CEO, M-Robo Inc.)

After working at the Korea Electrical Safety Corporation and the Maeil Business Newspaper, he founded M-Robo Inc., an external venture of Maeil Business Newspaper, where he currently serves as CEO. M-Robo Inc. is a media venture that began as an in-house venture of a news company. It provided a robot reporter service (StockBot) to the Kukmin Ilbo and has carried out numerous projects for organizations including the Korea Internet & Security Agency, the Korea Press Foundation, and the Korea Radio Promotion Association. It now runs its own AI news service, Money-Robo. While serving as CEO, he won the Asia Open Data Hackathon and received the Minister of the Interior and Safety Award twice for contributions to data entrepreneurship, and he is the inventor and registrant of five patents in artificial intelligence and blockchain. He is the author of the book “AI Crime and Self-Defense”, and he has developed e-learning content on fintech, statistics, and artificial intelligence for the Online Lifelong Education Institute of Korea University of Technology and Education. He holds a Ph.D. in economics (Dongguk University, mathematical microeconomics). He teaches data and AI courses at several universities, including Kookmin University and Hoseo University. Full profile

Courses

  • Ahn, Sangsun (2025). “Data Science for Business” (course materials). Department of AI Convergence, Open Cyber University of Korea.
  • Ahn, Sangsun (2025). [K-Digital] AI Natural Language Processing. STEP (Smart Training Education Platform), Online Lifelong Education Institute, Korea University of Technology and Education.
  • Ahn, Sangsun (2024). [K-Digital] Fintech Data Analysis Basics. STEP (Smart Training Education Platform), Online Lifelong Education Institute, Korea University of Technology and Education.

Go to the STEP courses: link.step.or.kr/1qyVoJ · link.step.or.kr/M9na9N · link.step.or.kr/brqEyc
If the links don’t work because of a site redesign, please go to www.step.or.kr.

Papers and Presentations

  • Ahn, Sangsun (2025). A study on household expenditure prediction models using the Korean Retirement and Income Study panel data: An AI model-based approach. “Future Society”, 16(2). Full text
  • Ahn, Sangsun (2025). A study on household expenditure prediction models using the Korean Retirement and Income Study panel data: An AI approach. Presentation at the KReIS Panel Conference (2025.05.13), National Pension Research Institute, National Pension Service. Slides
  • Ahn, Sangsun (2025). A study on an algorithm for detecting suspected drug transactions from SNS text: Focusing on pattern and context analysis. “Future Society”, 16(1). Full text
  • Ahn, Sangsun (2024). Statistics-based countermeasures against adversarial data for securing anomaly detection models in finance: Empirical analysis and simulation results. “Future Society”, 15(3). Full text
  • Ahn, Sangsun (2024). An AI-based solution for detecting SNS posts based on virtual character traits. Poster presentation at the 2024 Summer Newmedia Party (2024.06.19), Seoul Media Institute of Technology.
  • Ahn, Sangsun (2024). Machine learning models using industrial accident panel data. Poster presentation at the 10th Panel Study of Workers’ Compensation Insurance Conference (2024.05.17), Labor Welfare Research Institute, Korea Workers’ Compensation & Welfare Service.
  • Ahn, Sangsun (2024). Analysis and forecasting of virtual asset time-series data: Comparing time-series and AI models and suggesting improvements. “Future Society”, 15(1). Full text

E-2 Academic References

  1. [R1] Park, Haesun (2020). “Hands-On Machine Learning & Deep Learning (혼자 공부하는 머신러닝+딥러닝)”. Hanbit Media. Example code: rickiepark/hg-mldl (MIT License). Original data: Kaggle Fish Market dataset — Sections 1, 2, 6, Code 1
  2. [R2] Breiman, L., Friedman, J. H., Olshen, R. A., & Stone, C. J. (1984). Classification and Regression Trees. Wadsworth. — Section 3
  3. [R3] Rosenblatt, F. (1958). The perceptron: A probabilistic model for information storage and organization in the brain. Psychological Review, 65(6), 386–408. — Section 4
  4. [R4] Cortes, C., & Vapnik, V. (1995). Support-vector networks. Machine Learning, 20, 273–297. — Section 5
  5. [R5] Cover, T., & Hart, P. (1967). Nearest neighbor pattern classification. IEEE Transactions on Information Theory, 13(1), 21–27. — Section 6
  6. [R6] Alpaydin, E., & Kaynak, C. (1998). Optical recognition of handwritten digits [Dataset]. UCI Machine Learning Repository. (Original data for scikit-learn’s load_digits) — Code 2

E-3 Figure and Data Sources

  • The fish drawings in Section 1 are illustrative diagrams (proportions are approximate)
  • The fish dots in Sections 2, 4, and 5 are real measurements from [R1]. The perceptron’s starting line (w = [−1, 0.3], b = 0.6) and the order in which it sees the fish were chosen for illustration
  • The 80 photos in Sections 2 and 3 (+ 80 new photos) were made by shrinking the 12 images from episode 4-4 to 28 × 28 and changing their position and brightness. The two filters in Section 2 ② were chosen by hand

TIP for Educators

A guide for instructors, on-the-job training (OJT) leads, and tutors. Times are estimates, so adjust them to your actual class.

AudienceCollege students and working professionals new to machine learning: people who can handle Excel tables but have never worked with a model
PrerequisitesMean 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 TimeReading 35–45 min · hands-on demo 20 min · Colab practice 25 min (Code 1: 15 min, Code 2: 10 min)

Three Lesson Plans

50-min lecture

Concept-focused

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.

90-min on-the-job training

Work-focused

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.

1:1 tutoring

Paced by level

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.

Teaching Points by Section

SectionQuestions to pause and askInteraction 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

Top 5 Common Misconceptions

MisconceptionCorrect explanationScene to show
The perceptron was invented because SVM didn’t workIt’s the other way around. SVM (1990s) came after the perceptron (1958)Section 5 explanation
Anything that finds weights is a perceptronLinear SVM and logistic regression also find weights. The difference is the criterion for choosing the boundaryComparing the formulas in Sections 4 and 5
If you have enough features, you don’t need standardizationFor methods that use distances or weighted sums, different units can flip the resultThe (25cm, 150g) fish in Section 6
Rule-based models are outdatedFor table data whose features have meaning, they are still strong today and easy to explainThe one-line rule in Section 3
Photos are tables too, so the same methods workThe format is the same, but a single cell has no meaning, so you need a step that finds patternsSection 7 and Code 2

Check Questions (click to expand the explanations)

Q1. What are the number of samples, the number of features, and the target in the fish table?

49 samples (rows), 2 features (length and weight), and the target is a single column: bream 1 / smelt 0.

Q2. The perceptron wrongly called a bream (t = +1) a smelt. With z = (0.2, −0.1) and η = 0.5, how does w change?

w ← w + 0.5 × (+1) × (0.2, −0.1) = w + (0.1, −0.05). b increases by 0.5.

Q3. Do the perceptron and a linear SVM draw the same shape of boundary?

Yes. Both are straight lines where w·z + b = 0. SVM picks the one with the widest margin.

Q4. Why did the new fish (25cm, 150g) come out as a smelt with k-NN in the original units?

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).

Q5. If length were recorded in mm instead of cm, what would happen to the decision tree rule?

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.

Colab Assignments

Basic

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.

Challenge

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.

Adjusting Difficulty and Learning More

BeginnersYou 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
AdvancedHave 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 moreEasy Machine Learning with Fish Market Data (complete machine learning with the fish data) · Sangsun Ahn, “Data Science for Business” course materials
Instructor materialsGrading criteria for the Check Questions and sample answers to the assignments are on the answer page for educators (4-1)

Great work!

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.

Pixel art of the four lab crew members waving on a stage
Professor
ProfessorWe started from the difference between variables and features.
  • A variable is a named column; a feature is a pattern across many cells
  • For fish, rules, lines, and distances are enough
  • Different units, wrong distances
Assistant
AssistantThe pixel rule picked a background cell in the corner of the photo!
Fruit Fly Researcher
Fruit Fly ResearcherNext up, we crack photos open as numbers.