Skip to content

feat(models): add ContributionsPlotter for SHAP visualization#877

Merged
egordm merged 3 commits into
release/v4.0.0from
feature/841-openstef-40-plot-predict-contributions-shap
May 15, 2026
Merged

feat(models): add ContributionsPlotter for SHAP visualization#877
egordm merged 3 commits into
release/v4.0.0from
feature/841-openstef-40-plot-predict-contributions-shap

Conversation

@fleur-petit
Copy link
Copy Markdown
Collaborator

@fleur-petit fleur-petit commented May 8, 2026

Add ContributionsPlotter with heatmap, waterfall and bar chart methods for visualizing per-sample feature contributions (SHAP values).

✅ Acceptance criteria

Extended existing ContributionsMixin to include plotting method using ContibutionsPlotter.

One of 3 types of plots can be selected:

  • A heatmap with contributions for each timestamp
  • Waterfall for deep-dive contributions of feature contributions for a single timestamp
  • Bar plot with mean contributions

@github-actions github-actions Bot added the feature New feature or request label May 8, 2026
@fleur-petit fleur-petit force-pushed the feature/841-openstef-40-plot-predict-contributions-shap branch from 95a54d9 to 9c5fa72 Compare May 8, 2026 13:44
Add ContributionsPlotter with heatmap, waterfall and bar chart methods
for visualizing per-sample feature contributions (SHAP values).

Signed-off-by: Fleur Petit <fleur.petit@alliander.com>
@fleur-petit fleur-petit force-pushed the feature/841-openstef-40-plot-predict-contributions-shap branch from 9c5fa72 to 332174d Compare May 8, 2026 13:46
@fleur-petit fleur-petit marked this pull request as ready for review May 8, 2026 13:50
@fleur-petit fleur-petit requested a review from a team May 8, 2026 13:50
- Fix filename typo: contibutions_plotter.py -> contributions_plotter.py
- Update all imports to use corrected module name
- Remove unnecessary BaseConfig (Pydantic) inheritance from
  ContributionsPlotter — it's a static-method namespace, not a config model
- Add ValueError validation for invalid 'kind' in plot_contributions()
- Add Raises section to plot_contributions() docstring

Signed-off-by: Egor Dmitriev <egor.dmitriev@alliander.com>
Copy link
Copy Markdown
Collaborator

@egordm egordm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed a fixup commit (ad52360f) addressing a few things:

  • Renamed contibutions_plotter.pycontributions_plotter.py (typo) and updated imports
  • Removed BaseConfig inheritance from ContributionsPlotter — it only has static methods, no fields
  • plot_contributions() now raises ValueError for invalid kind values instead of a raw KeyError

All checks pass (lint, type, 20 tests).

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Collaborator

@egordm egordm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice addition to OpenSTEF. It adds visualization to the explainability capability. Thanks!

I had a few nitpicks, but I pushed a commit to fix them.

Ready to merge.

@egordm egordm merged commit bf201c5 into release/v4.0.0 May 15, 2026
4 checks passed
@egordm egordm deleted the feature/841-openstef-40-plot-predict-contributions-shap branch May 15, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants