Implement the **Recall (Sensitivity)** score for binary classification.
Formula:
Recall = TP / (TP + FN)
Where:
Write a function recall(y_true, y_pred) that returns the recall score.
Example:
y_true = [1, 0, 1, 1, 0, 1, 0, 1]
y_pred = [1, 0, 0, 1, 1, 1, 0, 1]
recall(y_true, y_pred) → 0.8
**Explanation:** There are 5 actual positives (indices 0,2,3,5,7). The model correctly predicted 4 of them (TP=4) and missed 1 (FN=1 at index 2). Recall = 4/5 = 0.8.
Constraints:
Test Cases
Test Case 1
Input:
y_true=[1,0,1,1,0,1,0,1], y_pred=[1,0,0,1,1,1,0,1]Expected:
0.8Test Case 2
Input:
y_true=[1,1,1], y_pred=[1,1,1]Expected:
1.0Test Case 3
Input:
y_true=[1,1,1], y_pred=[0,0,0]Expected:
0.0+ 2 hidden test cases