What is Supervised Learning?
Supervised learning is the most widely used category of machine learning. It is the engine behind spam filters, house price estimators, medical diagnostic tools and the vast majority of commercial AI applications you encounter every day. Understanding it is the essential first step to understanding how machine learning actually works.
The Core Idea: Learning from Examples
In supervised learning, you teach a model by showing it many examples where both the input and the correct answer are known. The model looks at enough of these examples to learn the relationship between inputs and outputs and then applies that relationship to new inputs it has never seen before.
Think of it like a student learning from a textbook with an answer key. The student reads the problem (input), checks the answer (label) and over many examples begins to understand the underlying pattern. Once that pattern is learned, the student can answer new questions that were not in the textbook.
Key Terminology
Input features (X): The data fed to the model. In a house price prediction problem, the features might be square footage, number of bedrooms, location and age of the property.
Labels (y): The correct output you want the model to predict. In house price prediction, the label is the actual sale price.
Training data: The collection of (input, label) pairs used to teach the model. The model never sees these inputs again once training is complete: but it has extracted the pattern.
Hypothesis function: The function the model learns that maps inputs to outputs. After training, this function should do a reasonable job of predicting y from X for examples it has never seen.
Prediction: When the trained model receives a new input and produces an output using its learned hypothesis function.
The Training Loop
During training, the model:
- Receives an input from the training set
- Produces a prediction using its current hypothesis function
- Compares the prediction to the known correct label
- Measures how wrong it was (the error or loss)
- Adjusts its internal parameters slightly to reduce that error
- Repeats this for every example in the training set, many times over
After thousands or millions of these adjustment cycles, the model's hypothesis function gets closer and closer to capturing the true relationship in the data.
Real-World Examples
Spam detection: Input features are words, sender, links and formatting in an email. The label is "spam" or "not spam." The model learns which combinations of features reliably indicate spam.
House price prediction: Input features are property characteristics. The label is the sale price. The model learns how each feature contributes to the price.
Medical diagnosis: Input features are patient measurements, symptoms and test results. The label is the presence or absence of a condition. The model learns the diagnostic patterns that doctors use.
Credit scoring: Input features are financial history, income and employment status. The label is whether the applicant repaid a previous loan. The model learns who is likely to repay.
Two Types of Supervised Learning
Regression is used when the label is a continuous number. You are predicting a quantity: a price, a temperature, a probability between 0 and 1. House price prediction is regression.
Classification is used when the label is a category. You are predicting which group something belongs to: spam or not spam, malignant or benign, cat or dog. Spam detection is classification.
The distinction matters because different algorithms, loss functions and evaluation metrics apply to each type. You will explore both in the lessons that follow.
Why "Supervised"?
The name comes from the fact that a human supervisor provides the correct answers during training. Someone had to manually label thousands of emails as spam or not spam. Someone had to compile a dataset of house sales with verified prices. The quality and accuracy of these labels directly determines how well the model can learn. If your labels are wrong, your model learns the wrong thing: no matter how sophisticated the algorithm.
Quiz: What is the difference between a label and a feature in a supervised learning problem? Give one example of a regression task and one example of a classification task.