In Machine Learning, data is generally divided into two important parts: features and labels. Features provide the input information to the model, while the label or target represents the output that the model is trying to predict.
Features = Input
Label / Target = Output
Features → Model → Label #
1. What Are Features? #
Simple Explanation #
Real-Life Example: House Price Prediction #
Suppose we want to predict the price of a house. We may use:
- Area of the house
- Number of bedrooms
- Number of bathrooms
- House age
- Location
These are the features because they provide information to the model.
2. Independent Variables #
Simple Explanation #
In supervised Machine Learning, features are often called independent variables. They are represented by variables such as:
X₁, X₂, X₃, … Xₙ
The model uses these variables to predict the dependent variable.
| Feature | Example Value |
|---|---|
| CGPA | 8.5 |
| Study Hours | 6 hours |
| Internship | Yes |
| Projects | 3 |
These variables are inputs to the model and can be treated as independent variables.
3. What Is a Label? #
Simple Explanation #
Example: Spam Detection #
Suppose our model receives information about emails. The features might include:
- Number of links
- Number of words
- Presence of suspicious words
- Sender information
The label can be:
- Spam
- Not Spam
4. Dependent Variable #
Simple Explanation #
The dependent variable is the output that depends on the input features. In Machine Learning, the dependent variable is commonly called the:
- Target
- Label
- Output variable
Suppose:
Area = 1500 sq ft
Bedrooms = 3
Age = 5 years
The model predicts:
House Price = ₹60 lakh
Here, house price is the dependent variable because it is the output we want to predict.
5. Feature Matrix X #
Simple Explanation #
In Machine Learning, the collection of input features is commonly represented by the capital letter:
X
When there are multiple samples and multiple features, X is called the feature matrix.
| CGPA | Study Hours | Projects | Placement |
|---|---|---|---|
| 8.5 | 6 | 3 | Yes |
| 7.2 | 4 | 2 | No |
| 9.1 | 7 | 4 | Yes |
The feature matrix X contains:
- CGPA
- Study Hours
- Projects
The Placement column is the target.
Feature Matrix Representation #
X = [
[8.5, 6, 3],
[7.2, 4, 2],
[9.1, 7, 4]
]
Here:
- Rows → Samples
- Columns → Features
6. Target Vector y #
Simple Explanation #
The target or label values are commonly represented using lowercase:
y
For a supervised Machine Learning problem, y contains the output values that the model is trying to predict.
y = [
"Yes",
"No",
"Yes"
]
In this example:
- X = student features
- y = placement labels
7. Understanding X and y Together #
Suppose we have the following dataset:
| CGPA | Study Hours | Projects | Placement |
|---|---|---|---|
| 8.5 | 6 | 3 | Yes |
| 7.2 | 4 | 2 | No |
| 9.1 | 7 | 4 | Yes |
Then:
X = [
[8.5, 6, 3],
[7.2, 4, 2],
[9.1, 7, 4]
]
y = [
"Yes",
"No",
"Yes"
]
X → Input Features
y → Target / Output
Model learns the relationship:
X → y
8. Independent Variable vs Dependent Variable #
| Concept | Meaning | Machine Learning Term | Symbol |
|---|---|---|---|
| Independent Variable | Input used to make a prediction | Feature | X |
| Dependent Variable | Output being predicted | Target / Label | y |
Independent Variable → Feature → X
Dependent Variable → Target/Label → y
9. Classification Example #
Email Spam Detection #
| Number of Words | Number of Links | Suspicious Words | Label |
|---|---|---|---|
| 100 | 5 | Yes | Spam |
| 50 | 1 | No | Not Spam |
| 120 | 8 | Yes | Spam |
Here:
X = Number of Words, Number of Links, Suspicious Words
y = Spam / Not Spam
10. Regression Example #
House Price Prediction #
For regression, the target is generally a numerical value.
| Area | Bedrooms | Age | Price |
|---|---|---|---|
| 1200 | 2 | 5 | ₹40 lakh |
| 1800 | 3 | 3 | ₹65 lakh |
| 2500 | 4 | 2 | ₹90 lakh |
Here:
X = Area, Bedrooms, Age
y = Price
11. Complete Feature → Label Workflow #
During training, the model receives both X and the corresponding y values in supervised learning. It learns a relationship between them. Later, when a new X is provided, the model produces a predicted output, commonly written as:
ŷ (y-hat)
X → Features / Inputs
y → Actual Target / Label
ŷ → Predicted Target
12. Quick Revision for Exams #
Features: Input variables used by the model.
Independent Variables: Variables used as inputs to predict the output.
Label: Known output associated with a training sample.
Dependent Variable: Output variable being predicted.
Feature Matrix X: Matrix containing input features for multiple samples.
Target Vector y: Vector containing the corresponding target values.
Prediction ŷ: Output predicted by the trained model.
13. One Diagram to Remember Everything #
Conclusion #
Features and labels are fundamental concepts in supervised Machine Learning. The easiest way to remember them is:
Label = Target = Dependent Variable = y
Prediction = ŷ
The model learns the relationship between X and y during training and then uses new feature values X to generate predictions ŷ.
Features and Labels in Machine Learning Quiz #
1. What is a feature in Machine Learning?
The final prediction made by a model
An input variable used by the model
The error of the model
The name of the algorithm
Explanation
A feature is an input variable or characteristic used by a Machine Learning model to learn patterns and make predictions.
2. What is another common name for a feature?
Dependent variable
Target variable
Independent variable
Prediction variable
Explanation
Features are commonly referred to as independent variables because they are used as inputs to predict the target or dependent variable.
3. In Machine Learning, what does the target or label represent?
Input data
Output that the model is trying to predict
Number of features
Training algorithm
Explanation
The target or label represents the known output associated with a training example and is the value the model is trying to predict.
4. Which symbol is commonly used to represent the feature matrix?
y
z
X
T
Explanation
The feature matrix is commonly represented by uppercase X and contains the input features for the samples.
5. If a dataset has 1,000 samples and 5 features, what is the typical shape of the feature matrix X?
(5, 1,000)
(1,000, 5)
(1,005)
(5, 5)
Explanation
The feature matrix X has 1,000 rows and 5 columns, so its shape is (1000, 5).
6. If X represents the features and y represents the actual target values, what does a trained model generally produce for a new X?
Another feature matrix only
A predicted target value ŷ
A new training dataset
A hyperparameter
Explanation
For a new input X, a trained Machine Learning model produces a predicted target value, commonly represented as ŷ (y-hat).
7. In a feature matrix X, what do the columns generally represent?
Samples
Predictions
Features
Labels only
Explanation
The columns of the feature matrix X generally represent the individual features or input variables.
8. In a house price prediction problem, which of the following can be a feature?
House price
Prediction error
Number of bedrooms
Model accuracy
Explanation
Number of bedrooms can be a feature because it is an input characteristic that can help predict the house price.
9. In a house price prediction problem, what is the dependent variable if the goal is to predict the house price?
Number of bedrooms
House area
House price
Location
Explanation
House price is the dependent variable because its value is being predicted using features such as area, bedrooms, and location.
10. Which statement correctly describes the relationship between X and y in supervised learning?
X contains targets and y contains features
X contains features and y contains target values
Both X and y contain only features
Both X and y contain model parameters
Explanation
In supervised learning, X contains the input features and y contains the corresponding target or label values.
11. What is the dependent variable also commonly called in Machine Learning?
Feature
Independent variable
Target or label
Hyperparameter
Explanation
The dependent variable is commonly called the target, label, or output variable in Machine Learning.
12. Suppose X contains student CGPA, study hours, and number of projects, while y contains Placement = Yes/No. What does y represent?
Feature matrix
Independent variables
Target vector
Hyperparameters
Explanation
y represents the target vector because it contains the placement labels that the model is trying to predict.
13. What does y-hat (ŷ) generally represent in Machine Learning?
Actual target value
Feature matrix
Predicted target value
Training dataset
Explanation
ŷ, pronounced y-hat, generally represents the value predicted by the trained Machine Learning model.
14. In a spam detection system, which of the following is most likely to be a label?
Number of words in an email
Number of links
Spam or Not Spam
Email length
Explanation
Spam or Not Spam is the label because it represents the output category that the model is trying to predict.
15. In a regression problem, which of the following can be a target variable y?
Number of bedrooms
House area
House price
Location
Explanation
House price can be the target variable y in a regression problem because it is a numerical value that the model is trying to predict.