EnsembleForecastingWorkflowConfig#

class openstef_meta.presets.EnsembleForecastingWorkflowConfig(*, kind: ~typing.Literal['ensemble'] = 'ensemble', model_id: ~openstef_models.mixins.model_serializer.ModelIdentifier, run_name: str | None = None, ensemble_type: ~typing.Literal['learned_weights', 'stacking', 'rules'] = 'learned_weights', base_models: ~collections.abc.Sequence[~typing.Literal['lgbm', 'gblinear', 'xgboost', 'lgbm_linear']] = ['lgbm', 'gblinear'], combiner_model: ~typing.Literal['lgbm', 'rf', 'xgboost', 'logistic', 'gblinear'] = 'lgbm', quantiles: list[~openstef_core.types.Quantile] = [0.5], sample_interval: ~datetime.timedelta = datetime.timedelta(seconds=900), horizons: list[~openstef_core.types.LeadTime] = [LeadTime('P2D')], location: ~openstef_models.presets.forecasting_workflow.LocationConfig = LocationConfig(name='test_location', description='', coordinate=Coordinate(latitude=52.132633, longitude=5.291266), country_code='NL'), school_holidays: ~openstef_models.transforms.time_domain.school_holiday_features_adder.SchoolHolidayConfig | None = None, xgboost_hyperparams: ~openstef_models.models.forecasting.xgboost_forecaster.XGBoostHyperParams = XGBoostHyperParams(n_estimators=100, learning_rate=0.3, max_depth=6, min_child_weight=1, gamma=0, objective='pinball_loss', evaluation_metric='mean_pinball_loss', reg_alpha=0, reg_lambda=1, max_delta_step=0, max_leaves=0, grow_policy='depthwise', max_bin=256, num_parallel_trees=1, subsample=1.0, colsample_bytree=1.0, colsample_bylevel=1.0, colsample_bynode=1.0, tree_method='auto', random_state=42, early_stopping_rounds=None, use_target_scaling=True), gblinear_hyperparams: ~openstef_models.models.forecasting.gblinear_forecaster.GBLinearHyperParams = GBLinearHyperParams(n_steps=500, updater='shotgun', learning_rate=0.15, objective='reg:quantileerror', evaluation_metric='mean_pinball_loss', reg_alpha=0.0001, reg_lambda=0.1, feature_selector='shuffle', top_k=0, random_state=None, early_stopping_rounds=10), lgbm_hyperparams: ~openstef_models.models.forecasting.lgbm_forecaster.LGBMHyperParams = LGBMHyperParams(n_estimators=100, learning_rate=0.49, max_depth=2, min_child_weight=1, min_data_in_leaf=10, min_data_in_bin=10, reg_alpha=0, reg_lambda=1, num_leaves=100, max_bin=256, colsample_bytree=1.0, early_stopping_rounds=None), lgbmlinear_hyperparams: ~openstef_models.models.forecasting.lgbmlinear_forecaster.LGBMLinearHyperParams = LGBMLinearHyperParams(n_estimators=100, learning_rate=0.07, max_depth=6, min_child_weight=0.06, min_data_in_leaf=500, min_data_in_bin=500, reg_alpha=0, reg_lambda=1, num_leaves=30, max_bin=256, colsample_bytree=1, early_stopping_rounds=None), combiner_lgbm_hyperparams: ~openstef_meta.models.forecast_combiners.learned_weights_combiner.LGBMCombinerHyperParams = LGBMCombinerHyperParams(n_estimators=20, n_leaves=31, reg_alpha=0.0, reg_lambda=0.0), combiner_rf_hyperparams: ~openstef_meta.models.forecast_combiners.learned_weights_combiner.RFCombinerHyperParams = RFCombinerHyperParams(n_estimators=20, n_leaves=31, bagging_freq=1, bagging_fraction=0.8, feature_fraction=1), combiner_xgboost_hyperparams: ~openstef_meta.models.forecast_combiners.learned_weights_combiner.XGBCombinerHyperParams = XGBCombinerHyperParams(n_estimators=20), combiner_logistic_hyperparams: ~openstef_meta.models.forecast_combiners.learned_weights_combiner.LogisticCombinerHyperParams = LogisticCombinerHyperParams(fit_intercept=True, penalty='l2', c=1.0), combiner_stacking_lgbm_hyperparams: ~openstef_models.models.forecasting.lgbm_forecaster.LGBMHyperParams = LGBMHyperParams(n_estimators=100, learning_rate=0.49, max_depth=2, min_child_weight=1, min_data_in_leaf=10, min_data_in_bin=10, reg_alpha=0, reg_lambda=1, num_leaves=100, max_bin=256, colsample_bytree=1.0, early_stopping_rounds=None), combiner_stacking_gblinear_hyperparams: ~openstef_models.models.forecasting.gblinear_forecaster.GBLinearHyperParams = GBLinearHyperParams(n_steps=500, updater='shotgun', learning_rate=0.15, objective='reg:quantileerror', evaluation_metric='mean_pinball_loss', reg_alpha=0.0001, reg_lambda=0.1, feature_selector='shuffle', top_k=0, random_state=None, early_stopping_rounds=10), target_column: str = 'load', energy_price_column: str = 'day_ahead_electricity_price', radiation_column: str = 'radiation', wind_speed_column: str = 'windspeed', pressure_column: str = 'pressure', temperature_column: str = 'temperature', relative_humidity_column: str = 'relative_humidity', selected_features: ~openstef_models.utils.feature_selection.FeatureSelection = FeatureSelection(include=None, include_regex=None, exclude=None, exclude_regex=None), predict_history: ~datetime.timedelta = datetime.timedelta(days=14), cutoff_history: ~datetime.timedelta = datetime.timedelta(0), completeness_threshold: float = 0.5, flatliner_threshold: ~datetime.timedelta = datetime.timedelta(days=1), detect_non_zero_flatliner: bool = False, predict_nonzero_flatliner: bool = False, shifters: list[~openstef_models.transforms.general.shifter.Shifter] = [], rolling_aggregate_features: list[~openstef_models.transforms.time_domain.rolling_aggregates_adder.AggregationFunction] = [], clip_features: ~openstef_models.utils.feature_selection.FeatureSelection = FeatureSelection(include=None, include_regex=None, exclude=None, exclude_regex=None), nan_on_outlier_features: ~openstef_models.utils.feature_selection.FeatureSelection = FeatureSelection(include=set(), include_regex=set(), exclude=None, exclude_regex=None), max_day_lags: int = 14, forecaster_sample_weights: dict[str, ~openstef_models.transforms.general.sample_weighter.SampleWeightConfig] = {'gblinear': SampleWeightConfig(method='inverse_frequency', weight_scale_percentile=95, weight_exponent=1.0, n_bins=50, dampening_exponent=0.5, weight_floor=0.1), 'lgbm': SampleWeightConfig(method='exponential', weight_scale_percentile=95, weight_exponent=0.0, n_bins=50, dampening_exponent=0.5, weight_floor=0.1), 'lgbm_linear': SampleWeightConfig(method='exponential', weight_scale_percentile=95, weight_exponent=0.0, n_bins=50, dampening_exponent=0.5, weight_floor=0.1), 'xgboost': SampleWeightConfig(method='exponential', weight_scale_percentile=95, weight_exponent=0.0, n_bins=50, dampening_exponent=0.5, weight_floor=0.1)}, combiner_sample_weight: ~openstef_models.transforms.general.sample_weighter.SampleWeightConfig = <factory>, data_splitter: ~openstef_models.utils.data_split.DataSplitter = DataSplitter(val_fraction=0.15, test_fraction=0.0, stratification_fraction=0.15, min_days_for_stratification=4, random_state=42), evaluation_metrics: list[~openstef_beam.evaluation.metric_providers.MetricProvider] = <factory>, mlflow_storage: ~openstef_models.integrations.mlflow.mlflow_storage.MLFlowStorage | None = <factory>, model_reuse_enable: bool = True, model_reuse_max_age: ~datetime.timedelta = datetime.timedelta(days=7), model_selection_enable: bool = True, model_selection_metric: tuple[~typing.Union[~openstef_core.types.Quantile, ~typing.Literal['global']], str, ~openstef_beam.evaluation.metric_providers.MetricDirection] = (0.5, 'R2', 'higher_is_better'), model_selection_old_model_penalty: float = 1.2, model_performance_callback_enabled: bool = False, model_performance_callback_metric_threshold: tuple[~typing.Union[~openstef_core.types.Quantile, ~typing.Literal['global']], str, ~openstef_beam.evaluation.metric_providers.MetricDirection, float] = (0.5, 'R2', 'higher_is_better', 0.0), verbosity: ~typing.Literal[0, 1, 2, 3, True] = 0, tags: dict[str, str] = <factory>, experiment_tags: dict[str, str] = <factory>)[source]#

Bases: BaseConfig

Configuration for ensemble forecasting workflows.

Parameters:
  • kind (Literal['ensemble'])

  • model_id (ModelIdentifier)

  • run_name (str | None)

  • ensemble_type (Literal['learned_weights', 'stacking', 'rules'])

  • base_models (Sequence[Literal['lgbm', 'gblinear', 'xgboost', 'lgbm_linear']])

  • combiner_model (Literal['lgbm', 'rf', 'xgboost', 'logistic', 'gblinear'])

  • quantiles (list[Quantile])

  • sample_interval (timedelta)

  • horizons (list[LeadTime])

  • location (LocationConfig)

  • school_holidays (SchoolHolidayConfig | None)

  • xgboost_hyperparams (XGBoostHyperParams)

  • gblinear_hyperparams (GBLinearHyperParams)

  • lgbm_hyperparams (LGBMHyperParams)

  • lgbmlinear_hyperparams (LGBMLinearHyperParams)

  • combiner_lgbm_hyperparams (LGBMCombinerHyperParams)

  • combiner_rf_hyperparams (RFCombinerHyperParams)

  • combiner_xgboost_hyperparams (XGBCombinerHyperParams)

  • combiner_logistic_hyperparams (LogisticCombinerHyperParams)

  • combiner_stacking_lgbm_hyperparams (LGBMHyperParams)

  • combiner_stacking_gblinear_hyperparams (GBLinearHyperParams)

  • target_column (str)

  • energy_price_column (str)

  • radiation_column (str)

  • wind_speed_column (str)

  • pressure_column (str)

  • temperature_column (str)

  • relative_humidity_column (str)

  • selected_features (FeatureSelection)

  • predict_history (timedelta)

  • cutoff_history (timedelta)

  • completeness_threshold (float)

  • flatliner_threshold (timedelta)

  • detect_non_zero_flatliner (bool)

  • predict_nonzero_flatliner (bool)

  • shifters (list[Shifter])

  • rolling_aggregate_features (list[AggregationFunction])

  • clip_features (FeatureSelection)

  • nan_on_outlier_features (FeatureSelection)

  • max_day_lags (int)

  • forecaster_sample_weights (dict[str, SampleWeightConfig])

  • combiner_sample_weight (SampleWeightConfig)

  • data_splitter (DataSplitter)

  • evaluation_metrics (list[MetricProvider])

  • mlflow_storage (MLFlowStorage | None)

  • model_reuse_enable (bool)

  • model_reuse_max_age (timedelta)

  • model_selection_enable (bool)

  • model_selection_metric (tuple[Union[Quantile, Literal['global']], str, MetricDirection])

  • model_selection_old_model_penalty (float)

  • model_performance_callback_enabled (bool)

  • model_performance_callback_metric_threshold (tuple[Union[Quantile, Literal['global']], str, MetricDirection, float])

  • verbosity (Literal[0, 1, 2, 3, True])

  • tags (dict[str, str])

  • experiment_tags (dict[str, str])

kind: Literal['ensemble']#

Discriminator tag for config type.

model_id: ModelIdentifier#

Unique identifier for the forecasting model.

run_name: str | None#

Optional name for this workflow run, can be used for versioning.

ensemble_type: Literal['learned_weights', 'stacking', 'rules']#
base_models: Sequence[Literal['lgbm', 'gblinear', 'xgboost', 'lgbm_linear']]#
combiner_model: Literal['lgbm', 'rf', 'xgboost', 'logistic', 'gblinear']#
quantiles: list[Quantile]#

List of quantiles to predict for probabilistic forecasting.

sample_interval: timedelta#

Time interval between consecutive data samples.

horizons: list[LeadTime]#

List of forecast horizons to predict.

location: LocationConfig#

Location information for the forecasting workflow.

school_holidays: SchoolHolidayConfig | None#

Opt-in school holiday features. None disables them.

xgboost_hyperparams: XGBoostHyperParams#

Hyperparameters for XGBoost forecaster.

gblinear_hyperparams: GBLinearHyperParams#

Hyperparameters for GBLinear forecaster.

lgbm_hyperparams: LGBMHyperParams#

Hyperparameters for LightGBM forecaster.

lgbmlinear_hyperparams: LGBMLinearHyperParams#

Hyperparameters for LightGBM forecaster.

combiner_lgbm_hyperparams: LGBMCombinerHyperParams#

Hyperparameters for LightGBM combiner.

combiner_rf_hyperparams: RFCombinerHyperParams#

Hyperparameters for Random Forest combiner.

combiner_xgboost_hyperparams: XGBCombinerHyperParams#

Hyperparameters for XGBoost combiner.

combiner_logistic_hyperparams: LogisticCombinerHyperParams#

Hyperparameters for Logistic Regression combiner.

combiner_stacking_lgbm_hyperparams: LGBMHyperParams#

Hyperparameters for LightGBM stacking combiner.

combiner_stacking_gblinear_hyperparams: GBLinearHyperParams#

Hyperparameters for GBLinear stacking combiner.

target_column: str#

Name of the target variable column in datasets.

energy_price_column: str#

Name of the energy price column in datasets.

radiation_column: str#

Name of the radiation column in datasets.

wind_speed_column: str#

Name of the wind speed column in datasets.

pressure_column: str#

Name of the pressure column in datasets.

temperature_column: str#

Name of the temperature column in datasets.

relative_humidity_column: str#

Name of the relative humidity column in datasets.

selected_features: FeatureSelection#

Feature selection for which features to include/exclude.

predict_history: timedelta#

Amount of historical data available at prediction time.

cutoff_history: timedelta#

Amount of historical data to exclude from training and prediction due to incomplete features from lag-based preprocessing. When using lag transforms (e.g., lag-14), the first N days contain NaN values. Set this to match your maximum lag duration (e.g., timedelta(days=14)). Default of 0 assumes no invalid rows are created by preprocessing. Note: should be same as predict_history if you are using lags. We default to disabled to keep the same behaviour as openstef 3.0.

completeness_threshold: float#

Minimum fraction of data that should be available for making a regular forecast.

flatliner_threshold: timedelta#

Number of minutes that the load has to be constant to detect a flatliner.

detect_non_zero_flatliner: bool#

If True, flatliners are also detected on non-zero values (median of the load).

predict_nonzero_flatliner: bool#

If True, predict the median of load measurements instead of zero (only for flatliner model).

shifters: list[Shifter]#

List of feature shifts to align aggregation intervals. Each Shifter can target different features with different aggregation periods.

rolling_aggregate_features: list[AggregationFunction]#

If not None, rolling aggregate(s) of load will be used as features in the model.

clip_features: FeatureSelection#

Feature selection for which features to clip to their learned range.

nan_on_outlier_features: FeatureSelection#

Feature selection for which features to replace out-of-range values with NaN. Defaults to no features (disabled).

max_day_lags: int#

Maximum number of days to look back for day-based lags. Default is 14 days (two weekly cycles). Set to 7 for a single weekly cycle.

forecaster_sample_weights: dict[str, SampleWeightConfig]#

Per-forecaster sample weighting configuration. Use weight_exponent=0 to produce uniform weights.

combiner_sample_weight: SampleWeightConfig#

Sample weighting configuration for the forecast combiner. Defaults to weight_exponent=0 (uniform weights).

data_splitter: DataSplitter#

Configuration for splitting data into training, validation, and test sets.

evaluation_metrics: list[MetricProvider]#

List of metric providers for evaluating model score.

mlflow_storage: MLFlowStorage | None#

Configuration for MLflow experiment tracking and model storage.

model_reuse_enable: bool#

Whether to enable reuse of previously trained models.

model_reuse_max_age: timedelta#

Maximum age of a model to be considered for reuse.

model_selection_enable: bool#

Whether to enable automatic model selection based on performance.

model_selection_metric: tuple[Union[Quantile, Literal['global']], str, MetricDirection]#

Metric to monitor for model performance when retraining.

model_selection_old_model_penalty: float#

Penalty to apply to the old model’s metric to bias selection towards newer models.

model_performance_callback_enabled: bool#

Whether to enable the ModelPerformanceCallback that evaluates model performance at the end of fitting.

model_performance_callback_metric_threshold: tuple[Union[Quantile, Literal['global']], str, MetricDirection, float]#

Metric to monitor for model performance threshold at the end of fitting.

verbosity: Literal[0, 1, 2, 3, True]#

Verbosity level. 0=silent, 1=warning, 2=info, 3=debug

tags: dict[str, str]#

Optional metadata tags for the model.

experiment_tags: dict[str, str]#

Optional metadata tags for experiment tracking.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': False, 'extra': 'ignore', 'protected_namespaces': ()}#

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