ModelContributionsPlotter#
- class openstef_models.explainability.ModelContributionsPlotter[source]#
Bases:
objectVisualize learned per-model weights alongside the ensemble forecast.
- static plot_stacked_area(contributions: TimeSeriesDataset, forecast: ForecastDataset, quantile: Quantile = Q(0.5), target_column: str = 'load') go.Figure[source]#
Create a stacked-area plot of per-model weights with the ensemble prediction.
The top panel shows the ensemble prediction for the requested quantile. The bottom panel shows each base model’s selection weight as a stacked area (summing to 1.0), so you can see how the combiner distributes weight across models at each timestep.
- Parameters:
contributions (
TimeSeriesDataset) – Per-model selection weights from a learned-weightsEnsembleForecastingModel. Use the result ofpredict_contributions()or the second element ofpredict_with_contributions(). Columns contain model weights for each forecast quantile.forecast (
ForecastDataset) – Output ofEnsembleForecastingModel.predict()or the first element ofEnsembleForecastingModel.predict_with_contributions(). Must contain a column for the requested quantile.quantile (
Quantile) – Forecast quantile to show in both panels. DefaultQ(0.5).target_column (
str) – Name of the target column to exclude from contributions. Default"load".contributions
forecast
quantile
target_column
- Returns:
Plotly Figure with a prediction line (top) and stacked-area model weights (bottom).
- Raises:
ValueError – If no contribution columns match the requested quantile.
KeyError – If the forecast dataset has no column for the requested quantile.
- Return type:
Figure