---
title: Features and Labels in Machine Learning
description: "Features and Labels in Machine Learning 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…"
url: "https://csestudy247.com/docs/features-and-labels-in-machine-learning/"
updated: "2026-09-23"
category: ML
---

# Features and Labels in Machine Learning

Features and Labels in Machine Learning

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.

  **Easy Definition:**

 **Features = Input**

 **Label / Target = Output**

## Features → Model → Label

 graph LR A\["📊 Features Input Variables"\] B\["🤖 Machine Learning Model"\] C\["🎯 Label / Target Output"\] A --> B B --> C style A fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style B fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px style C fill:#28a745,color:#fff,stroke:#333,stroke-width:4px

---

## 1. What Are Features?

### Simple Explanation

  **Features** are the input variables or characteristics that a Machine Learning model uses to learn patterns and make predictions.

### Real-Life Example: House Price Prediction

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

  graph TD A\["🏠 House"\] A --> B\["📐 Area"\] A --> C\["🛏️ Bedrooms"\] A --> D\["🚿 Bathrooms"\] A --> E\["📅 Age"\] A --> F\["📍 Location"\] B --> G\["🤖 ML Model"\] C --> G D --> G E --> G F --> G G --> H\["💰 Predicted Price"\] style A fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px style B fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style C fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style D fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style E fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style F fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style G fill:#ff9800,color:#fff,stroke:#333,stroke-width:3px style H fill:#28a745,color:#fff,stroke:#333,stroke-width:4px  **Exam Definition:** A feature is an input variable or measurable characteristic used by a Machine Learning model to make predictions.   **Remember:** Feature → **Input used by 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.

   📌 Example: Student Placement

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

   **Exam Definition:** Independent variables are input variables used to explain or predict the dependent variable.   **Easy Trick:** Independent Variable = **Input**

---

## 3. What Is a Label?

### Simple Explanation

  A **label** is the known output associated with a training example in supervised Machine Learning. It is the value that the model learns to predict.

### Example: Spam Detection

   📧 Email 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**

  graph LR A\["📧 Email Features"\] B\["🤖 ML Model"\] C\["🏷️ Label"\] A --> B B --> C C --> D\["Spam / Not Spam"\] style A fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style B fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px style C fill:#ff9800,color:#fff,stroke:#333,stroke-width:3px style D fill:#28a745,color:#fff,stroke:#333,stroke-width:4px  **Exam Definition:** A label is the known output or target value associated with a training sample in supervised Machine Learning.   **Remember:** Label → **What the model should predict**

---

## 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

   🏠 House Price Example

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.

   **Exam Definition:** The dependent variable is the output variable whose value is predicted or explained using one or more independent variables.   **Easy Trick:** Dependent Variable = **Output / Target**

---

## 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**.

   📊 Example Dataset

| 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

 graph TD A\["Feature Matrix X"\] A --> B\["Rows"\] A --> C\["Columns"\] B --> D\["Samples"\] C --> E\["Features"\] style A fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px style B fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style C fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style D fill:#28a745,color:#fff,stroke:#333,stroke-width:3px style E fill:#28a745,color:#fff,stroke:#333,stroke-width:3px  **Exam Definition:** The feature matrix **X** is a matrix containing the input features for all samples in a Machine Learning dataset.   **Remember:** **X = Features / Inputs**

---

## 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

 graph LR A\["X Feature Matrix"\] B\["🤖 ML Model"\] C\["y Target Vector"\] A --> B B --> C style A fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style B fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px style C fill:#28a745,color:#fff,stroke:#333,stroke-width:4px  **Exam Definition:** The target vector **y** contains the target or output values corresponding to the samples in the feature matrix X.   **Remember:** **y = Target / Label / Output**

---

## 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"
]
```

  graph LR A\["X Feature Matrix"\] A --> B\["CGPA"\] A --> C\["Study Hours"\] A --> D\["Projects"\] E\["y Target Vector"\] E --> F\["Yes"\] E --> G\["No"\] E --> H\["Yes"\] style A fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style B fill:#005cbf,color:#fff,stroke:#333,stroke-width:2px style C fill:#005cbf,color:#fff,stroke:#333,stroke-width:2px style D fill:#005cbf,color:#fff,stroke:#333,stroke-width:2px style E fill:#28a745,color:#fff,stroke:#333,stroke-width:4px style F fill:#28a745,color:#fff,stroke:#333,stroke-width:2px style G fill:#28a745,color:#fff,stroke:#333,stroke-width:2px style H fill:#28a745,color:#fff,stroke:#333,stroke-width:2px  **Most Important Formula:**

 **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 |

  **Exam Shortcut:**

 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**

  For classification problems, the target **y** usually represents a category or class. Examples: **Spam / Not Spam**, **Cat / Dog**, **Yes / No**.

---

## 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**

  In regression, the target **y** is generally a continuous numerical value such as price, salary, temperature, or house area.

---

## 11. Complete Feature → Label Workflow

 graph TD A\["📊 Dataset"\] A --> B\["X = Features"\] A --> C\["y = Label / Target"\] B --> D\["🤖 Machine Learning Model"\] C --> D D --> E\["🧠 Learn Relationship X → y"\] E --> F\["📥 New Input X"\] F --> G\["🔮 Prediction ŷ"\] style A fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px style B fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style C fill:#28a745,color:#fff,stroke:#333,stroke-width:4px style D fill:#ff9800,color:#fff,stroke:#333,stroke-width:3px style E fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px style F fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style G fill:#28a745,color:#fff,stroke:#333,stroke-width:4px

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

  **Important Symbols:**

 **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

 graph LR A\["📥 Input Data"\] B\["X Feature Matrix"\] C\["🤖 ML Model"\] D\["y Actual Target"\] E\["ŷ Predicted Target"\] A --> B B --> C D --> C C --> E B -. "Independent Variables" .-> C D -. "Dependent Variable" .-> C style A fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px style B fill:#005cbf,color:#fff,stroke:#333,stroke-width:4px style C fill:#ff9800,color:#fff,stroke:#333,stroke-width:3px style D fill:#28a745,color:#fff,stroke:#333,stroke-width:4px style E fill:#e91e63,color:#fff,stroke:#333,stroke-width:4px

## Conclusion

Features and labels are fundamental concepts in supervised Machine Learning. The easiest way to remember them is:

  **Features = Input = Independent Variables = X

 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

    Features provide input information to the Machine Learning model.    [Discuss it](#)

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

    Features are commonly treated as the inputs to a supervised learning model.    [Discuss it](#)

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

    The target is the value the model learns to predict.    [Discuss it](#)

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

    The feature matrix is conventionally represented using an uppercase letter.    [Discuss it](#)

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)

    Rows represent samples and columns represent features.    [Discuss it](#)

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

    The model uses new input features to generate an estimated output.    [Discuss it](#)

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

    Think of each column as one characteristic measured for every sample.    [Discuss it](#)

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

    Features are inputs that help the model predict the house price.    [Discuss it](#)

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

    The dependent variable is the output being predicted.    [Discuss it](#)

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

    Remember: X = inputs and y = actual outputs.    [Discuss it](#)

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

    The output being predicted has several common names.    [Discuss it](#)

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

    The Yes/No values are the outputs that the model needs to predict.    [Discuss it](#)

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

    The hat symbol indicates that the value is estimated or predicted.    [Discuss it](#)

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

    The label is the category the model is trying to predict.    [Discuss it](#)

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

    Regression generally predicts a numerical output.    [Discuss it](#)

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.
