Plots¶
plots
¶
Matplotlib visualization helpers for fitted FlagGAM estimators and diagnostics.
This module is an ORIGINAL ADDITION and is not part of Zhao & Welsch
(arXiv:2605.31189): the paper specifies no plotting API. matplotlib is an
OPTIONAL dependency (pip install flaggam[viz]); importing this module never
imports matplotlib eagerly. Every function calls _plt() first, which raises
a helpful ImportError if matplotlib is not installed, so import flaggam
and import flaggam.plots both work without matplotlib present.
plot_shape
¶
Plot the fitted additive contribution for one feature.
Numeric features get a step curve of contribution vs. value over the
range spanned by that feature's discovered cutoffs (padded 10%), plus a
rug of the cutoffs themselves. Categorical features get one bar per
discovered level, height equal to that level's coefficient. Requires
representation='full' (the compact head's coefficients are per-class
scores, not per-basis weights).
Source code in src/flaggam/plots.py
plot_rule_importance
¶
Horizontal bar chart of the top top_n rules by |weight| from export_rules().
Source code in src/flaggam/plots.py
plot_waterfall
¶
Cumulative horizontal bars from intercept to total score for one row.
Rules are sorted by |contribution| and collapsed beyond max_rules into
a single "(other rules)" bucket; the final bar marks the total score.
Source code in src/flaggam/plots.py
plot_reliability
¶
plot_reliability(y_true: Any, y_prob: Any, n_bins: int = 10, strategy: str = 'uniform', ax: Axes | None = None) -> Axes
Reliability diagram: mean predicted vs. observed rate, with per-bin counts.
Source code in src/flaggam/plots.py
plot_proxy_association
¶
Horizontal bars of rule-level proxy association, flagged rules highlighted.
Source code in src/flaggam/plots.py
plot_group_metrics
¶
Grouped bar chart of selection_rate/tpr/auroc per protected-attribute group.