Recall Metric in Binary Classification
Core Metrics DS practice problem on Onlearn.
Difficulty: easy.
Topics: Recall Metric in Binary Classification, True Positive Rate, False Negative Rate, Sensitivity, Type II Error, Recall-Precision Trade-off, Supervised Learning, Statistical Inference, Information Theory, Performance Benchmarking, Decision Theory, Binary Classification, Confusion Matrix Analysis, Error Rate Estimation, Cost-Sensitive Learning, Model Diagnostic Frameworks.
Task: Implement Recall in Binary Classification Your task is to implement the recall metric in a binary classification setting. Recall is a performance measure that evaluates how effectively a machine learning model identifies positive instances from all the actual positive cases in a dataset. You need to write a function recall(y true, y pred) that calculates the recall metric. The function should accept two inputs: y true: A list of true binary labels (0 or 1) for the dataset. y pred: A list of predicted binary labels (0 or 1) from the model. Your function should return the recall value as a float. If the denominator (TP + FN) is zero, return 0.0 to avoid division by zero.