ModelContributionsPlotter#

class openstef_models.explainability.plotters.ModelContributionsPlotter[source]

Bases: object

Visualize 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') → 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-weights EnsembleForecastingModel. Use the result of predict_contributions() or the second element of predict_with_contributions(). Columns contain model weights for each forecast quantile.

  • forecast (ForecastDataset) – Output of EnsembleForecastingModel.predict() or the first element of EnsembleForecastingModel.predict_with_contributions(). Must contain a column for the requested quantile.

  • quantile (Quantile) – Forecast quantile to show in both panels. Default Q(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