What Are Labels?
A label is the known answer that a Machine Learning model is trained to predict.
Features tell the model what it knows. The label tells it what it should learn to predict.
In supervised Machine Learning, training examples contain both input information and a known answer.
Start With a House Price Example
Suppose we want to build a model that predicts the selling price of a house.
We have historical examples where the actual selling price is already known.
Size, bedrooms, and age can be used as features. The actual price is the value we want the model to predict.
The Label Is the Known Answer
During training, the model sees examples where the correct answer is already available.
The terms label and target are often used interchangeably in Machine Learning.
Features vs Label
Consider this simple dataset:
| Size | Bedrooms | Age | Price |
|---|---|---|---|
| 1800 | 3 | 8 | $320,000 |
| 2200 | 4 | 5 | $410,000 |
| 1400 | 2 | 15 | $240,000 |
Information given to the model.
Value the model needs to predict.
Labels Can Be Numbers
A label does not have to be a category. It can be a numerical value.
$320,000
32°C
When the label is a continuous numerical value, the problem is commonly treated as a regression problem.
Labels Can Be Categories
A label can also represent a category or class.
One possible class.
Another possible class.
Predicting a category is commonly called a classification problem.
Example: Spam Detection
Suppose we have an email dataset.
The features describe the email. The label tells us whether that email was actually spam.
Why Does the Model Need Labels?
During supervised learning, the model needs examples where the correct answer is known.
Information about the example.
Compare predictions with known answers.
The correct result for training.
By comparing its predictions with the known labels, the learning algorithm can adjust the model so that its predictions become more useful.
What Happens When We Predict Something New?
Suppose a new house enters the system.
We give the available features to the trained model.
We don't know the actual price yet. That is exactly what we are trying to predict.
Training Data Has Labels
Historical training examples normally contain both the input features and their known labels in supervised learning.
Test Data Also Has Known Labels
This is an important distinction.
When we evaluate a model on a test dataset, the test labels are known to us. They are simply hidden from the model during prediction.
We keep the actual answers separate so we can compare the model's predictions against them after prediction.
A Common Mistake
Beginners sometimes think the label is simply "the last column" of a dataset.
That's wrong.
The same dataset can have different labels depending on what you want the model to predict.
A customer dataset could use next-month spending as the label.
The same customer dataset could instead use whether the customer will cancel as the label.
Features and Labels Together
Inputs used by the model.
Finds useful patterns.
Known answer we want to predict.
In many Machine Learning libraries and tutorials, X is used for features and y is used for the target or label.
Features Are Inputs. Labels Are Answers.
Features describe the examples. Labels provide the known outcomes that a supervised Machine Learning model learns to predict.
Find the Label
You want to predict whether a customer will cancel their subscription.
Your dataset contains:
- Customer age.
- Number of months as a customer.
- Number of support requests.
- Monthly subscription price.
- Whether the customer cancelled.
The first four values can be features.
"Whether the customer cancelled" is the label because that is the outcome we want to predict.