Skip to content

Add SHAP-like beeswarm plot visualization#357

Merged
y0z merged 2 commits intooptuna:mainfrom
yasumorishima:feat/plot-beeswarm
Mar 13, 2026
Merged

Add SHAP-like beeswarm plot visualization#357
y0z merged 2 commits intooptuna:mainfrom
yasumorishima:feat/plot-beeswarm

Conversation

@yasumorishima
Copy link
Contributor

Summary

Add plot_beeswarm visualization package that creates SHAP-style beeswarm plots for Optuna studies.

Closes #116

Motivation

Requested in optuna/optuna#4987 and redirected to OptunaHub in #116. Beeswarm plots reveal monotonic relationships between hyperparameter values and objective function values, complementing existing visualizations like slice plot and parallel coordinate plot.

What it does

  • X-axis: Objective function value
  • Y-axis: Parameters sorted by importance (most important at top)
  • Color: Normalized parameter value (blue=low, red=high)
  • Vertical spread: Density-based jitter — wider where trials are concentrated

Beeswarm Plot Example

Implementation details

  • Histogram-based density estimation for beeswarm jitter (no scipy dependency)
  • Parameter sorting: fANOVA (via optuna.importance) with Spearman rank correlation fallback when sklearn is unavailable
  • Dependencies: only matplotlib and numpy (already common in Optuna ecosystem)

Files

package/visualization/plot_beeswarm/
├── __init__.py    # plot_beeswarm() function
├── README.md      # Documentation with frontmatter
├── example.py     # Minimal working example
├── LICENSE        # MIT
└── images/
    └── beeswarm.png

Checklist

  • Pre-commit hooks pass (ruff, ruff-format, mypy, mdformat)
  • Minimal working example provided
  • Sample image included
  • I agree to the contributor agreements

@c-bata
Copy link
Member

c-bata commented Mar 13, 2026

LGTM! Thank you for your contribution.

y0z added a commit that referenced this pull request Mar 13, 2026
Follow-up #357: Update example.py for `plot_beeswarm`.
@y0z y0z merged commit fb87d44 into optuna:main Mar 13, 2026
3 checks passed
@y0z
Copy link
Member

y0z commented Mar 13, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding SHAP-like beeswarm plot

3 participants