Skip to content

feat(plotly): implement confusion-matrix#2284

Merged
github-actions[bot] merged 4 commits intomainfrom
implementation/confusion-matrix/plotly
Dec 26, 2025
Merged

feat(plotly): implement confusion-matrix#2284
github-actions[bot] merged 4 commits intomainfrom
implementation/confusion-matrix/plotly

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Implementation: confusion-matrix - plotly

Implements the plotly version of confusion-matrix.

File: plots/confusion-matrix/implementations/plotly.py


🤖 impl-generate workflow

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Dec 26, 2025

AI Review - Attempt 1/3

Image Description

The plot displays a 4×4 confusion matrix heatmap for a sentiment analysis classifier with four classes: Negative, Neutral, Positive, and Very Positive. The matrix uses a sequential Blues colormap ranging from light (low values ~1-15) to dark blue (high values ~70-85). The y-axis shows "True Label" and x-axis shows "Predicted Label". Each cell contains white or black numeric annotations showing the count values (white text on dark backgrounds, black text on light backgrounds). The title "confusion-matrix · plotly · pyplots.ai" is centered at the top. A colorbar on the right shows the "Count" scale from approximately 1-85. The diagonal cells (correct predictions) are darker blue, clearly showing the model performs well with most predictions on the diagonal. The matrix is square with equal cell dimensions, and all text is clearly legible.

Quality Score: 93/100

Criteria Checklist

Visual Quality (38/40 pts)

  • VQ-01: Text Legibility (10/10) - Title at 28pt, axis labels at 22pt, tick labels at 18pt, cell annotations at 24pt - all perfectly readable
  • VQ-02: No Overlap (8/8) - No overlapping text, all labels clearly separated
  • VQ-03: Element Visibility (8/8) - Cells are well-sized, colormap distinguishes values effectively
  • VQ-04: Color Accessibility (5/5) - Blues colormap is colorblind-safe sequential palette
  • VQ-05: Layout Balance (5/5) - Square layout with good margins, plot fills canvas well
  • VQ-06: Axis Labels (1/2) - Descriptive labels ("True Label", "Predicted Label") but no units needed for categorical data
  • VQ-07: Grid & Legend (1/2) - Colorbar well placed with appropriate sizing, no grid needed for heatmap

Spec Compliance (25/25 pts)

  • SC-01: Plot Type (8/8) - Correct confusion matrix heatmap visualization
  • SC-02: Data Mapping (5/5) - True labels on Y-axis, Predicted labels on X-axis as specified
  • SC-03: Required Features (5/5) - Annotated cells with counts, colorbar, sequential colormap, clear axis labeling
  • SC-04: Data Range (3/3) - All data visible, appropriate scale
  • SC-05: Legend Accuracy (2/2) - Colorbar accurately shows count scale
  • SC-06: Title Format (2/2) - Correctly uses "confusion-matrix · plotly · pyplots.ai" format

Data Quality (20/20 pts)

  • DQ-01: Feature Coverage (8/8) - Shows true positives on diagonal, off-diagonal misclassifications, adjacent class confusion pattern
  • DQ-02: Realistic Context (7/7) - Sentiment analysis is a real, comprehensible scenario with 4 classes
  • DQ-03: Appropriate Scale (5/5) - Counts in realistic range (1-85), class sizes balanced

Code Quality (10/10 pts)

  • CQ-01: KISS Structure (3/3) - Simple imports → data → plot → save structure, no functions/classes
  • CQ-02: Reproducibility (3/3) - Uses np.random.seed(42)
  • CQ-03: Clean Imports (2/2) - Only numpy and plotly.graph_objects imported, both used
  • CQ-04: No Deprecated API (1/1) - Uses current Plotly API
  • CQ-05: Output Correct (1/1) - Saves as plot.png and plot.html

Library Features (5/5 pts)

  • LF-01: Uses distinctive library features (5/5) - Custom hovertemplate for interactivity, graph_objects for fine control, plotly_white template, scale anchoring for square cells

Strengths

  • Excellent use of Plotly's hovertemplate for interactive tooltips showing "True: {y}, Predicted: {x}, Count: {z}"
  • Smart text color contrast logic - white text on dark cells, black text on light cells
  • Square cells using scaleanchor ensures proper matrix visualization
  • Clean, professional appearance with plotly_white template
  • Realistic sentiment analysis data with believable misclassification patterns (adjacent classes confused more often)

Weaknesses

  • Image dimensions (1200×1200 with scale=3 = 3600×3600) differ slightly from the standard 4800×2700 landscape format, though square format is appropriate for confusion matrices
  • VQ-06: Axis labels could be slightly more descriptive (e.g., "True Sentiment Class" vs "True Label")

Verdict: APPROVED

@github-actions github-actions Bot added the quality:93 Quality score 93/100 label Dec 26, 2025
@github-actions github-actions Bot added the ai-approved Quality OK, ready for merge label Dec 26, 2025
@github-actions github-actions Bot merged commit e5da956 into main Dec 26, 2025
3 checks passed
@github-actions github-actions Bot deleted the implementation/confusion-matrix/plotly branch December 26, 2025 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-approved Quality OK, ready for merge quality:93 Quality score 93/100

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants