Recall Practice Problem
This data science coding problem helps you practice Evaluation Metrics for Classification, recall, and implementation skills. Read the problem statement, write your solution, and strengthen your understanding of Evaluation Metrics for Classification.
- Problem ID: 151
- Problem key: 151-recall
- URL: https://datacrack.app/solve/151-recall
- Difficulty: easy
- Topic: Evaluation Metrics for Classification
- Module: Introduction to Machine Learning
Problem Statement
## š§© Recall Score
### šÆ Goal
Compute the **recall** of a binary classification model.
---
### š„ Input / š¤ Output
**Input**
- `y_true` (`list[int]`): true labels (0 or 1)
- `y_pred` (`list[int]`): predicted labels (0 or 1)
ā
**Assumption:**
- `y_true` and `y_pred` have the same non-zero length.
- Labels are binary (0 or 1).
**Output**
- `float`: recall score
---
### š» Task Description
Recall measures how well the model **finds all actual positive cases**.
It is defined as:
$$
\text{Recall} = \frac{TP}{TP + FN}
$$
where:
- **TP (True Positives)**: predicted 1 and actually 1
- **FN (False Negatives)**: predicted 0 but actually 1
---
### š§© Starter Code
```python
def recall_score(y_true, y_pred):
"""
Returns the Recall Score.
"""
pass
```
---
### š” Example
```python
y_true = [1, 0, 1, 1, 0]
y_pred = [1, 1, 1, 0, 0]
recall_score(y_true, y_pred)
```
**Expected Output**
```
0.6666666667
```
(2 true positives out of 3 actual positives)
---
Starter Code
def recall_score(y_true, y_pred):
"""
Returns the Recall Score.
"""
pass