OpenSTEF4BacktestForecaster#

class openstef_beam.benchmarking.baselines.openstef4.OpenSTEF4BacktestForecaster(*, config: BacktestForecasterConfig, workflow_template: CustomForecastingWorkflow, cache_dir: Path, debug: bool = False, contributions: bool = False, extra_callbacks: list[ForecastingCallback] = <factory>)[source]

Bases: BaseModel, BacktestForecasterMixin

Forecaster that allows using a ForecastingWorkflow to be used in backtesting, specifically for OpenSTEF4 models.

A new workflow is created each time fit() is called using the provided workflow_factory, ensuring fresh model instances for each training cycle during benchmarking.

Parameters:
config: BacktestForecasterConfig
workflow_template: CustomForecastingWorkflow
cache_dir: Path
debug: bool
contributions: bool
extra_callbacks: list[ForecastingCallback]
model_post_init(context: Any) → None[source]

Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.

Parameters:

context (Any)

Return type:

None

Overrides:

BaseModel.model_post_init

property quantiles: list[Quantile]

Return the list of quantiles that this forecaster predicts.

Overrides:

BacktestForecasterMixin.quantiles

fit(data: RestrictedHorizonVersionedTimeSeries) → None[source]

Handles the training of the model.

Parameters:

data (RestrictedHorizonVersionedTimeSeries) – Time series data with context for training.

Return type:

None

Overrides:

BacktestForecasterMixin.fit

predict(data: RestrictedHorizonVersionedTimeSeries) → TimeSeriesDataset | None[source]

Core prediction logic to be implemented by subclasses.

Parameters:

data (RestrictedHorizonVersionedTimeSeries) – Time series data with context for prediction.

Return type:

TimeSeriesDataset | None

Returns:

DataFrame with predictions or None if prediction cannot be performed.
  • The predictions should be formatted in quantile columns [quantile_PXX]

  • The index should be the timestamp of the prediction

Overrides:

BacktestForecasterMixin.predict

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'protected_namespaces': (), 'ser_json_inf_nan': 'null'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].