XGBoostHyperParams#

class openstef_models.models.forecasting.xgboost_forecaster.XGBoostHyperParams(**data: Any) None[source]

Bases: HyperParams

XGBoost hyperparameters for gradient boosting tree models.

Configures tree-specific parameters for XGBoost gbtree booster. Provides control over model complexity, regularization, and training behavior for energy forecasting tasks.

These parameters control tree structure, learning rates, regularization, and sampling strategies. Proper tuning is essential for balancing model performance and overfitting prevention in time series forecasting.

Example

Creating custom hyperparameters for deep trees with regularization

>>> hyperparams = XGBoostHyperParams(
...     n_estimators=200,
...     max_depth=8,
...     learning_rate=0.1,
...     reg_alpha=0.1,
...     reg_lambda=1.0,
...     subsample=0.8,
... )

Note

These parameters are optimized for probabilistic forecasting with quantile regression. The default objective function is specialized for magnitude-weighted pinball loss.

Parameters:

data (Any)

n_estimators: Annotated[int]
learning_rate: Annotated[float]
max_depth: Annotated[int]
min_child_weight: Annotated[float]
gamma: Annotated[float]
objective: TypeAliasType
evaluation_metric: TypeAliasType
reg_alpha: Annotated[float]
reg_lambda: Annotated[float]
max_delta_step: float
max_leaves: int
grow_policy: Annotated[Literal['depthwise', 'lossguide']]
max_bin: int
num_parallel_trees: int
subsample: Annotated[float]
colsample_bytree: Annotated[float]
colsample_bylevel: float
colsample_bynode: float
tree_method: Annotated[Literal['auto', 'exact', 'hist', 'approx', 'gpu_hist']]
random_state: int | None
early_stopping_rounds: int | None
use_target_scaling: bool
classmethod forecaster_class() type[XGBoostForecaster][source]

Get the forecaster class for these hyperparams.

Return type:

type[XGBoostForecaster]

Returns:

Forecaster class associated with this configuration.

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].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

  • self

  • context

Return type:

None