ContributionsPlotter#
- class openstef_models.explainability.ContributionsPlotter[source]#
Bases:
objectVisualizations for per-timestep feature contributions.
- static plot_heatmap(contributions: TimeSeriesDataset, top_n: int = 10, target_column: str = 'load', bias_column: str = 'bias', *, show_prediction: bool = True) Figure[source]#
Create an interactive heatmap of feature contributions over time.
X-axis is the prediction datetime, Y-axis shows feature names ranked by mean absolute contribution (most important at top). Color ranges from blue (negative) through white (zero) to red (positive). When
show_predictionis True a line plot of the model prediction (sum of contributions + bias) is shown above the heatmap.- Parameters:
contributions (
TimeSeriesDataset) – Output ofpredict_contributions().top_n (
int) – Number of top features to show (ranked by mean absolute contribution).target_column (
str) – Name of the target column to exclude. Default “load”.bias_column (
str) – Name of the bias column. Default “bias”.show_prediction (
bool) – If True, add a prediction line subplot above the heatmap. Default True.contributions
top_n
target_column
bias_column
show_prediction
- Returns:
Plotly Figure with a diverging heatmap centered at zero (and optional prediction line).
- Return type:
Figure
- static plot_waterfall(contributions: TimeSeriesDataset, timestep: int = 0, top_n: int = 10, target_column: str = 'load', bias_column: str = 'bias') Figure[source]#
Create a waterfall chart decomposing a single timestep’s prediction.
Shows how the bias (base value) is pushed up or down by each feature’s contribution to arrive at the final prediction.
- Parameters:
contributions (
TimeSeriesDataset) – Output ofpredict_contributions().timestep (
int) – Row index (0-based) of the timestep to explain.top_n (
int) – Number of top features to show. Remaining features are aggregated into an “other” bar.target_column (
str) – Name of the target column to exclude. Default “load”.bias_column (
str) – Name of the bias column used as base value. Default “bias”.contributions
timestep
top_n
target_column
bias_column
- Returns:
Plotly Figure with waterfall chart.
- Return type:
Figure
- static plot_bar(contributions: TimeSeriesDataset, top_n: int = 10, target_column: str = 'load', bias_column: str = 'bias') Figure[source]#
Create a horizontal bar chart of mean absolute contributions per feature.
Features are ranked from most to least important (top to bottom).
- Parameters:
contributions (
TimeSeriesDataset) – Output ofpredict_contributions().top_n (
int) – Number of top features to show.target_column (
str) – Name of the target column to exclude. Default “load”.bias_column (
str) – Name of the bias column to exclude. Default “bias”.contributions
top_n
target_column
bias_column
- Returns:
Plotly Figure with horizontal bar chart.
- Return type:
Figure