Generate a Confusion Matrix for Binary Classification
Core Metrics DS practice problem on Onlearn.
Difficulty: easy.
Topics: Understanding Generate a Confusion Matrix for Binary Classification, True Positives, False Negatives, Type I Error, Sensitivity Analysis, Precision-Recall Tradeoff, Model Evaluation & Selection, Statistical Inference, Information Theory, Data Quality Assurance, Supervised Learning, Classification Performance Metrics, Error Analysis, Predictive Modeling, Binary Outcome Assessment, Diagnostic Testing.
Task: Generate a Confusion Matrix Your task is to implement the function confusion matrix(data) that generates a confusion matrix for a binary classification problem. The confusion matrix provides a summary of the prediction results on a classification problem, allowing you to visualize how many data points were correctly or incorrectly labeled. Input: A list of lists, where each inner list represents a pair [y true, y pred] for one observation. y true is the actual label, and y pred is the predicted label. Output: A $2 \times 2$ confusion matrix represented as a list of lists.