Supervised Learning — Learning with a Teacher
Supervised Learning: the ML paradigm where someone diligently labeled things beforehand.
When you study with flashcards, the correct answer is already on the back before you flip — that is the core principle of supervised learning. The machine sees thousands of such flashcards (data with correct answers) and learns to predict the answer for cards it has never seen before.
In the previous article you learned that ML models learn from data instead of following explicit rules. Now we look at the most common form of that learning: supervised learning, where every training example comes with a correct answer attached.
Features & Labels — The Raw Material
Definition
Feature & Label
Analogy
Definition
The flashcard analogy has a productive side-effect: you might think the model eventually memorizes the cards. That is actually a real problem — it is called overfitting, and we will come back to it shortly.
Concrete example: A spam filter receives 10,000 labeled emails. Features are word frequencies, sender domain, and link count. Labels: "spam" or "not spam" (assigned by humans). The model sees 8,000 labeled emails during training and must correctly classify the remaining 2,000 it has never seen.
Labels are not always correct. Human annotators sometimes disagree, make mistakes, or apply inconsistent criteria. For a spam filter, one annotator might mark a newsletter as spam while another does not.
A model trained on noisy labels learns the teacher's errors as if they were correct patterns. The quality of labels determines the ceiling of model performance just as much as their quantity.
Interactive: Feature-Label Mapping
In the spam filter example above, you saw how features and labels work together. Here you can try for yourself how three email features affect the prediction. The weights (×2, ×3, −5) and the threshold of 7 are fixed here — in supervised learning, the model would learn exactly these numbers from the labeled emails.
Feature-Label Mapping
Three features of an email determine whether it is classified as spam. Move the sliders and observe how the prediction changes.
3×2 + 2×3 − 0 = 12Classification vs. Regression — Two Flavors of Prediction
Depending on the type of label, supervised learning tasks fall into two fundamental categories. The distinction is determined entirely by the nature of the label — not by the features.
Predicts discrete categories — like a sorting machine that asks: "Which bin does this belong to?" Examples: spam/not-spam, cat/dog/bird, benign/malignant.
Predicts continuous numerical values — like a scale that asks: "How much does this weigh?" Examples: house price in euros, temperature in degrees, stock price.
Same dataset, different questions: With patient data, the question "Is the tumor benign or malignant?" becomes classification (label is 0 or 1). The question "How large will the tumor be in six months (in mm)?" becomes regression (label is a continuous measurement). Same features, different label type, completely different ML approach.
Gray area: A product rating (1–5 stars) can be treated as regression ("predict 4.2 stars") or as 5-class classification. The choice depends on whether the distance between 3 and 4 stars matters as a metric.
Interactive: Supervised vs. Unsupervised vs. Semi-Supervised
Between “everything labeled” and “nothing labeled” there are hybrid forms. The diagram shows one of them: semi-supervised learning.
The Supervised Learning Workflow
Supervised learning follows a fixed five-step pipeline. The most important safeguard: the train-test split — it reveals whether the model has merely memorized the data.
- 1. Collect & label data
- 2. Split: ~80% training, ~20% test
- 3. Choose & train a model
- 4. Evaluate on test data
- 5. Deploy modelinference — applying the model to real, new data
Think of exam preparation: you practice with exercises (training set), but the real exam (test set) contains problems you have never seen. If you only memorized the practice answers without understanding the underlying principles, you fail the exam. That is overfitting.
Don't worry, you don't need to be able to code — this just shows how short the workflow is in practice. In Python with scikit-learn:
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.datasets import load_diabetes
X, y = load_diabetes(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
model = LinearRegression().fit(X_train, y_train)
print(f"Test Score: {model.score(X_test, y_test):.2f}")Line 5 loads data with features (X) and labels (y). Line 6 splits 80/20. Line 7 trains a linear regression model. Line 8 evaluates it on the unseen test data. The dataset contains measurements from 442 diabetes patients; the label is a number for disease progression one year later — hence regression. The score (R²) is 1.0 for a perfect prediction and 0 for a model that stubbornly guesses the average. Here you will usually land just under 0.5, a bit higher or lower depending on the random split – normal for this tough dataset. Overfitting only shows up as a large gap to the score on the training data.
Caution
Common Misconceptions
- "Labels are always correct." — In reality, label noise is a real problem. Annotators make mistakes, and the model learns these mistakes as patterns.
- "More data always helps." — More bad labels make the model worse. Quality beats quantity.
- "The boundary between classification and regression is always clear." — Star ratings (1–5) can be treated as either.
Transfer learning allows you to take a model pre-trained on millions of examples and adapt it to a new task with just a few hundred labeled data points. The pre-trained model has already learned general patterns (e.g., edges and textures for images), so often only the final decision layer needs to be retrained.
Practical example: A company has only 200 labeled images for product recognition. With a model pre-trained on ImageNet (millions of images), these 200 examples are sufficient to train a working classifier.
ImageNet: The Dataset That Changed Everything
The creation of the dataset that made Deep Learning possible. In 2009, Fei-Fei Li and her team presented the ImageNet paper, introducing a visual database that would transform computer vision — at launch it contained around 3.2 million hand-annotated images in approximately 5,200 categories. Expanded to its full size, ImageNet later comprised over 14 million hand-annotated images and around 22,000 categories, based on WordNet hierarchies, addressing the critical bottleneck: the shortage of large, high-quality training data. Annotation was carried out throughout the project by around 49,000 workers from 167 countries via Amazon Mechanical Turk — an unprecedentedly collaborative effort. What began as a poster in a corner of a Miami Beach convention center grew into the annual ImageNet Challenge (ILSVRC) and became one of the three drivers of modern AI development. ImageNet enabled AlexNet's 2012 breakthrough and laid the foundation for autonomous vehicles, facial recognition, and medical imaging.
Note
Key Takeaways
- Supervised learning needs labeled data — features (input) paired with labels (correct output). Without labels, the model has no teacher.
- Classification predicts categories (spam/not-spam), regression predicts numbers (house price in euros). The same data can serve both depending on the question asked.
- The train-test split is the single most important safeguard: a model that only performs well on data it has already seen (overfitting) is useless in the real world.
Check
Quiz: Supervised Learning
What is a "label" in a supervised learning dataset?
Select one answer
1. What is a "label" in a supervised learning dataset?
2. A hospital wants to predict whether a patient has diabetes (yes/no) based on blood tests. What type of supervised learning task is this?
3. A real estate company has data on 5,000 apartments (size, floor, location) with their sale prices. They split the data 80/20. The model scores 0.99 on training data but only 0.45 on test data. What is the most likely problem?
4. An online shop has product ratings from 1 to 5 stars. A developer wants to predict ratings for new products. She could treat this as classification (5 classes) or regression (predict a number). Which consideration is most relevant?
5. A team trains a spam filter on 10,000 emails. They discover that 500 emails were incorrectly labeled (spam marked as not-spam and vice versa). What is the most accurate description of the impact?
6. A company has only 200 labeled images but needs an image classifier. A colleague suggests transfer learning with a model pre-trained on millions of images. Why can this work despite the small dataset?
Check
Comprehension Check
Can you explain this in your own words? Tick what you've got.
0 of 3 done