Perform a Deep Confusion Matrix Analysis to Diagnose Model Errors

Diagnose model errors through deep confusion matrix analysis with derived metrics, error patterns, and targeted improvement plans.

๐Ÿ“ The Prompt

Act as an expert in machine learning model diagnostics. Analyze the following confusion matrix and provide a comprehensive error diagnosis. **Confusion Matrix:** ``` [PASTE_CONFUSION_MATRIX โ€” e.g., a 2D array or formatted table with actual vs. predicted labels] ``` **Class Labels (in order):** [LIST_CLASS_LABELS] **Problem Context:** - Task description: [TASK_DESCRIPTION] - Model used: [MODEL_NAME] - Total dataset size: [DATASET_SIZE] - Known data quality issues (if any): [DATA_ISSUES] **Please deliver the following analysis:** 1. **Matrix interpretation:** Walk through the confusion matrix cell by cell, explaining what each value means in plain language using the actual class names from [LIST_CLASS_LABELS]. Highlight true positives, true negatives, false positives, and false negatives for each class. 2. **Derived metrics calculation:** From the matrix, manually compute and present: accuracy, precision, recall, specificity, and F1-score for each class. Show the formulas used. 3. **Error pattern identification:** Identify the most common misclassification pairs. For each pair, explain which class is being confused with which and hypothesize why this confusion might occur in the context of [TASK_DESCRIPTION]. 4. **Class imbalance impact:** Assess whether class imbalance is inflating or deflating overall accuracy. Calculate and compare accuracy vs. balanced accuracy. 5. **Visualization recommendations:** Suggest 2-3 visualization techniques (e.g., normalized confusion matrix, error heatmap, per-class bar charts) and explain what each would reveal. 6. **Targeted improvement plan:** For the top 3 most problematic misclassification pairs, provide specific remediation strategies including: feature engineering ideas, data collection suggestions, model architecture changes, or post-processing rules. 7. **Threshold analysis (for binary):** If binary classification, recommend how adjusting the decision threshold would shift the matrix and which direction to adjust based on the problem's cost structure. Format with clear sections, tables for computed metrics, and prioritized recommendations.

๐Ÿ’ก Tips for Better Results

Include the actual class label names rather than just numbers โ€” this enables context-aware hypotheses about why specific confusions occur. For multi-class problems, mention any known similarities between classes that might explain misclassifications. Providing the model name helps the AI suggest architecture-specific improvements.

๐ŸŽฏ Use Cases

ML practitioners and data analysts use this after model training to systematically identify where the model fails and prioritize debugging efforts for maximum performance gains.

๐Ÿ”— Related Prompts

๐Ÿ“Š Data & Analytics intermediate

Write Complex SQL Queries

Generate optimized SQL queries for complex analysis with CTEs, JOINs, and performance tips.

๐Ÿ“Š Data & Analytics intermediate

Python Data Analysis Script

Generate a complete Python data analysis pipeline with cleaning, visualization, and insights.

๐Ÿ“Š Data & Analytics intermediate

Build an RFM Customer Segmentation Model for Targeted Marketing

Create a complete RFM customer segmentation model with scoring logic, code implementation, and marketing strategies.

๐Ÿ“Š Data & Analytics advanced

Design a Robust ETL Pipeline Architecture for Your Data Platform

Design a complete ETL pipeline architecture with extraction, transformation, loading strategies, error handling, and governance.

๐Ÿ“Š Data & Analytics intermediate

Create a Comprehensive Data Quality Checklist for Your Dataset

Generate a tailored data quality checklist with SQL validation queries, severity levels, and a scoring framework for any dataset.

๐Ÿ“Š Data & Analytics advanced

Analyze and Interpret A/B Test Results with Statistical Rigor

Get a complete A/B test analysis with statistical significance, power analysis, validity checks, and a clear ship decision.