Skip to content

feat(altair): implement ice-basic#5945

Merged
MarkusNeusinger merged 5 commits into
mainfrom
implementation/ice-basic/altair
May 7, 2026
Merged

feat(altair): implement ice-basic#5945
MarkusNeusinger merged 5 commits into
mainfrom
implementation/ice-basic/altair

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 7, 2026

Implementation: ice-basic - python/altair

Implements the python/altair version of ice-basic.

File: plots/ice-basic/implementations/python/altair.py

Parent Issue: #5238


🤖 impl-generate workflow

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 7, 2026

AI Review - Attempt 1/3

Image Description

Light render (plot-light.png): The plot renders on a warm off-white (#FAF8F1) background. The title "House Price Predictions · ice-basic · altair · anyplot.ai" appears in dark ink at the top. The X-axis is labeled "Square Footage (sq ft)" and the Y-axis "Predicted Price ($K)" — both in dark text with readable tick labels. 100 semi-transparent green (#009E73) ICE lines form a dense band fanning from ~$100–200K at 800 sq ft to ~$400–620K at 3500 sq ft. A bold orange (#D55E00) PDP line runs through the center of the band and stands out prominently. Small grey rug tick marks appear along the bottom of the x-axis. All text is clearly readable against the light background — no contrast issues.

Dark render (plot-dark.png): The same plot on a warm near-black (#1A1A17) background. Title, axis labels, and tick labels flip to light cream/grey text — all readable against the dark surface. The ICE lines remain the identical #009E73 green as the light render (correct theme-invariance), and the orange PDP line is unchanged. The semi-transparent ICE band appears richer on the dark surface. No dark-on-dark failures observed — the theme adaptation is correct throughout. Both renders pass legibility checks.

Score: 85/100

Category Score Max
Visual Quality 29 30
Design Excellence 11 20
Spec Compliance 14 15
Data Quality 14 15
Code Quality 10 10
Library Mastery 7 10
Total 85 100

Visual Quality (29/30)

  • VQ-01: Text Legibility (8/8) — All font sizes explicitly set: title 28px, axis 22px, ticks 18px, legend 16px. Readable in both themes.
  • VQ-02: No Overlap (6/6) — No text overlaps. Rug plot below the x-axis causes no interference.
  • VQ-03: Element Visibility (5/6) — PDP line (strokeWidth=5) is highly visible. ICE lines at opacity=0.10 form a readable density band; faintest tails are barely visible individually.
  • VQ-04: Color Accessibility (2/2) — #009E73 and #D55E00 are CVD-safe Okabe-Ito colors with strong mutual contrast.
  • VQ-05: Layout & Canvas (4/4) — 4800×2700px; chart fills canvas well with balanced margins.
  • VQ-06: Axis Labels & Title (2/2) — "Square Footage (sq ft)" and "Predicted Price ($K)" — descriptive with units.
  • VQ-07: Palette Compliance (2/2) — ICE lines #009E73 (Okabe-Ito Add workflow diagram for new prototype discovery #1), PDP #D55E00 (Okabe-Ito Add Claude Code GitHub Workflow #2). Backgrounds #FAF8F1/#1A1A17 correct. Data colors identical across themes.

Design Excellence (11/20)

  • DE-01: Aesthetic Sophistication (5/8) — Above configured default: thoughtful three-layer composition (ICE + PDP + rug), appropriate opacity for 100 lines, correct Okabe-Ito pairing. Not exceptional — no legend, no annotation highlighting the key PDP insight.
  • DE-02: Visual Refinement (3/6) — Grid is subtle (opacity=0.10). However, configure_view(stroke=INK_SOFT) creates a visible four-sided border frame — top/right borders reduce visual refinement and should be suppressed.
  • DE-03: Data Storytelling (3/6) — Bold PDP line stands out from the green ICE band, creating visual hierarchy. However, the PDP line is completely unlabeled — no legend, no annotation — so the key insight (average vs. individual effect) is invisible to anyone unfamiliar with ICE plots.

Spec Compliance (14/15)

  • SC-01: Plot Type (5/5) — ICE plot with individual per-observation lines. PDP overlay correct.
  • SC-02: Required Features (4/4) — Semi-transparent ICE lines, bold PDP overlay, rug plot — all three spec features present.
  • SC-03: Data Mapping (3/3) — X=sqft, Y=price_k, detail=obs_id (one line per observation).
  • SC-04: Title & Legend (2/3) — Title contains spec-id, library, anyplot.ai. No legend present — ICE lines vs. PDP line are unlabeled.

Data Quality (14/15)

  • DQ-01: Feature Coverage (5/6) — Shows ICE spread, PDP overlay, and data distribution via rug. Missing color-coding by a second feature (e.g., bedroom count) that would reveal interaction effects — the most informative ICE variant.
  • DQ-02: Realistic Context (5/5) — GradientBoostingRegressor on house price data — a canonical ML interpretability use case. Neutral and non-controversial.
  • DQ-03: Appropriate Scale (4/4) — Price $60K–$620K, sqft 800–3500, age 0–50 years. Model captures plausible non-linear sqft effect.

Code Quality (10/10)

  • CQ-01: KISS Structure (3/3) — Flat flow: theme tokens → data → model → ICE computation → chart layers → save.
  • CQ-02: Reproducibility (2/2) — np.random.seed(42) and GradientBoostingRegressor(random_state=42).
  • CQ-03: Clean Imports (2/2) — All imports used; sys/os for path handling, sklearn for the model.
  • CQ-04: Code Elegance (2/2) — Clean, Pythonic. sys.path manipulation is a legitimate pattern here.
  • CQ-05: Output & API (1/1) — Saves plot-{THEME}.png and plot-{THEME}.html. Correct for altair.

Library Mastery (7/10)

  • LM-01: Idiomatic Usage (4/5) — Uses alt.layer(), detail encoding for multi-line, alt.value() for rug position, configure_* for theme. Idiomatic but doesn't leverage selections or advanced encodings.
  • LM-02: Distinctive Features (3/5) — detail encoding (Altair-specific for individual lines without a color legend), alt.value() for fixed pixel position, and HTML interactive export are all Altair-distinctive.

Score Caps Applied

  • None applied

Strengths

  • Correct Okabe-Ito palette: #009E73 for ICE lines and #D55E00 for PDP follows canonical Okabe-Ito order
  • All font sizes explicitly set at correct pixel values (28/22/18/16px) for the large canvas
  • Theme-adaptive chrome correctly implemented — all ink tokens flip between light and dark renders
  • Excellent data context: real GradientBoostingRegressor trained on synthetic house data, ICE curves genuinely computed
  • Three-layer composition (ICE + PDP + rug) with thoughtful opacity settings
  • Idiomatic Altair: detail encoding for individual lines and alt.value() for rug position

Weaknesses

  • No legend: the plot has no label distinguishing the green ICE lines from the orange PDP line — a viewer cannot understand which curve is which without domain knowledge
  • configure_view(stroke=INK_SOFT) creates a visible four-sided border — top/right sides should be suppressed for visual refinement
  • The PDP line (the key average-effect insight) has no annotation or legend entry pointing to it, weakening data storytelling
  • Could add color-coding of ICE lines by a second feature (e.g., bedroom count) to reveal interaction effects, as suggested in the spec

Issues Found

  1. SC-04 / DE-03 WEAK: No legend distinguishing ICE lines vs. PDP line
    • Fix: Add a manual legend or inline label. In Altair, use alt.Chart(pd.DataFrame({'label': ['ICE curves', 'PDP (mean)'], 'color': [BRAND, PDP_COLOR]})) to build a legend, or add a text mark annotation on the PDP line at its right end.
  2. DE-02 WEAK: Four-sided border frame via configure_view(stroke=INK_SOFT)
    • Fix: Set stroke=None in configure_view() to eliminate all borders, or use strokeWidth=0.
  3. DE-03 WEAK: PDP line unlabeled, no visual hierarchy annotation
    • Fix: Add a text mark at the rightmost PDP point labeling it "Average (PDP)" to anchor the viewer's eye on the key insight.

AI Feedback for Next Attempt

Add a legend or inline label identifying the green ICE lines and the orange PDP line — this is the single most impactful missing element. Set configure_view(stroke=None) to remove the four-sided border (only an L-shaped or borderless frame should remain). Optionally annotate the PDP line at its right end with a text mark. These three changes directly address the Design Excellence and Spec Compliance gaps. Data and Code quality are already strong — focus the repair on storytelling and chrome refinement.

Verdict: REJECTED

@github-actions github-actions Bot added quality:85 Quality score 85/100 ai-rejected Quality not OK, triggers update labels May 7, 2026
@github-actions github-actions Bot added ai-attempt-1 First repair attempt and removed ai-rejected Quality not OK, triggers update labels May 7, 2026
Attempt 1/3 - fixes based on AI review
@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented May 7, 2026

🔧 Repair Attempt 1/4

Applied fixes based on AI review feedback.

Status: Repair completed, re-triggering review...


🤖 impl-repair

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 7, 2026

AI Review - Attempt 2/3

Image Description

Light render (plot-light.png): The plot renders on a warm off-white background (#FAF8F1), not pure white. The title "ice-basic · altair · anyplot.ai" is centered at the top in dark ink and clearly readable. One hundred semi-transparent ICE lines in #009E73 (brand green) at 10% opacity form a visible teal density band spanning 800–3500 sq ft on the x-axis and roughly $40K–$620K on the y-axis. A bold orange-vermillion (#D55E00) PDP line (strokeWidth=5) overlays the band, immediately drawing the eye. A "Partial Dependence" annotation in matching orange appears at approximately 2400 sq ft, mid-chart — readable but overlapping with the densest part of the ICE band. Rug marks are visible along the x-axis bottom. Axis labels ("Square Footage (sq ft)", "Predicted Price ($K)") and tick labels are all readable. A small legend in the top-right lists "ICE Curves" and "Partial Dependence." All text is legible against the light background.

Dark render (plot-dark.png): The background is near-black (#1A1A17), not pure black. Title and axis labels render in light-colored ink (#F0EFE8) and are clearly readable against the dark surface. Tick labels in INK_SOFT (#B8B7B0) are visible. The ICE curve color is identical to the light render (#009E73 green band) — data colors correctly unchanged. The PDP line remains in the same #D55E00 orange. The legend box uses the ELEVATED_BG (#242420) fill with a soft stroke border. No dark-on-dark failures observed — all text is appropriately light-colored against the dark background. Brand green #009E73 remains clearly visible on the dark surface.

Both paragraphs are required. A review that only describes one render is invalid.

Score: 89/100

Category Score Max
Visual Quality 29 30
Design Excellence 13 20
Spec Compliance 15 15
Data Quality 15 15
Code Quality 10 10
Library Mastery 7 10
Total 89 100

Visual Quality (29/30)

  • VQ-01: Text Legibility (8/8) — All font sizes explicitly set: title=28px, axis=22px, ticks=18px, legend=16px. Readable in both themes.
  • VQ-02: No Overlap (5/6) — Annotation placed at ~2400 sqft where ICE density is highest, creating slight visual clutter mid-chart. Main content readable.
  • VQ-03: Element Visibility (6/6) — 10% opacity appropriate for 100 ICE lines. Bold PDP line (strokeWidth=5) clearly visible. Rug ticks visible at bottom.
  • VQ-04: Color Accessibility (2/2) — Okabe-Ito CVD-safe palette. ICE vs PDP distinguished by color + stroke weight + opacity, not hue alone.
  • VQ-05: Layout & Canvas (4/4) — Plot fills canvas well at 1600×900. Legend in top-right does not isolate. Good margins.
  • VQ-06: Axis Labels & Title (2/2) — X: "Square Footage (sq ft)", Y: "Predicted Price ($K)" — descriptive with units.
  • VQ-07: Palette Compliance (2/2) — First series #009E73, second #D55E00 (Okabe-Ito order 1→2). Backgrounds correct (#FAF8F1 / #1A1A17). Chrome correctly theme-adapted in both renders.

Design Excellence (13/20)

  • DE-01: Aesthetic Sophistication (5/8) — Thoughtful Okabe-Ito 2-color scheme with intentional semi-transparency for density visualization. Clearly above well-configured defaults but not FiveThirtyEight publication level.
  • DE-02: Visual Refinement (4/6) — Subtle grid (10% opacity), view border removed (strokeWidth=0), refined INK_SOFT axis colors, legend with ELEVATED_BG fill and soft stroke. Good refinement.
  • DE-03: Data Storytelling (4/6) — Visual hierarchy achieved through bold+opaque PDP vs. transparent ICE. Rug plot adds distribution context. Annotation labels PDP. Good storytelling; could be stronger by emphasizing heterogeneous subgroup behavior.

Spec Compliance (15/15)

  • SC-01: Plot Type (5/5) — Correct ICE plot with individual lines per observation via detail channel.
  • SC-02: Required Features (4/4) — Low-alpha individual lines, bold PDP overlay, rug plot — all spec notes implemented.
  • SC-03: Data Mapping (3/3) — sqft on x, price_k on y, detail=obs_id:N creates correct per-observation grouping.
  • SC-04: Title & Legend (3/3) — Title "ice-basic · altair · anyplot.ai" correct. Legend labels "ICE Curves" and "Partial Dependence" descriptive.

Data Quality (15/15)

  • DQ-01: Feature Coverage (6/6) — 100 observations × 60 grid points with GBR model showing non-linear ICE curves and heterogeneous spread.
  • DQ-02: Realistic Context (5/5) — House price prediction with GradientBoostingRegressor — realistic, neutral, comprehensible domain.
  • DQ-03: Appropriate Scale (4/4) — 800–3500 sqft range and $40K–$620K predicted prices plausible for residential housing.

Code Quality (10/10)

  • CQ-01: KISS Structure (3/3) — Linear: imports → data → model → ICE computation → plot → save. No functions or classes.
  • CQ-02: Reproducibility (2/2) — np.random.seed(42) set.
  • CQ-03: Clean Imports (2/2) — All imports (os, sys, altair, numpy, pandas, sklearn) are used.
  • CQ-04: Code Elegance (2/2) — Clean Pythonic code, appropriate complexity.
  • CQ-05: Output & API (1/1) — Saves plot-{THEME}.png and plot-{THEME}.html. Current Altair 6.1.0 API.

Library Mastery (7/10)

  • LM-01: Idiomatic Usage (4/5) — Good Altair usage: detail channel for per-observation grouped lines, alt.layer() composition, shared color scale with legend across layers, configure_* for global theme.
  • LM-02: Distinctive Features (3/5) — detail:N channel for line grouping (Vega-Lite grammar of graphics feature), mark_tick for rug plot, shared color scale propagated across layered charts.

Score Caps Applied

  • None applied. DE-01=5 (>2) and DE-02=4 (>2), so the 75-point cap does not trigger.

Strengths

  • Perfect spec compliance: ICE lines with low alpha, bold PDP overlay, and rug plot all correctly implemented
  • Correct Okabe-Ito 2-color scheme (#009E73 ICE, #D55E00 PDP) with shared legend scale across layers
  • Full theme-adaptive chrome using correct token values for both light and dark renders
  • All font sizes explicitly set to spec-correct pixel values
  • Realistic house price GBR model with sensible feature ranges and plausible price values
  • Clean KISS code structure with deterministic seed and all imports used

Weaknesses

  • PDP annotation placed at ~2400 sqft (mid-chart) where ICE density is highest — text overlaps dense line region; placing it near the right edge (nlargest(5, "sqft")) would reduce visual clutter
  • Design storytelling could be stronger — no emphasis on observations that diverge most from PDP, which is the key insight ICE plots are meant to reveal

Issues Found

  1. VQ-02 MINOR: Annotation "Partial Dependence" positioned mid-chart in densest ICE region
    • Fix: Move annotation to near-rightmost sqft value where lines fan out and overlap is lower

AI Feedback for Next Attempt

The implementation is well-executed overall. If a repair is needed: (1) move the PDP annotation to the right edge of the chart where line density is lower; (2) consider adding a storytelling element by coloring or emphasizing the top/bottom decile of ICE lines to highlight heterogeneous effects — this directly serves the stated purpose of ICE plots.

Verdict: APPROVED

@github-actions github-actions Bot added quality:89 Quality score 89/100 ai-approved Quality OK, ready for merge and removed quality:85 Quality score 85/100 labels May 7, 2026
@MarkusNeusinger MarkusNeusinger merged commit c02e065 into main May 7, 2026
@MarkusNeusinger MarkusNeusinger deleted the implementation/ice-basic/altair branch May 7, 2026 17:11
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 ai-attempt-1 First repair attempt quality:89 Quality score 89/100

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant