energy_methods.xgboost#

Deterministic CPU XGBoost regression for explicitly prepared forecast features.

This module neither creates lags nor splits time series. Fit only on information available before the issue time. References: Chen and Guestrin (2016), and the official XGBoost Python API. JSON model state is exported instead of pickle.

class energy_methods.xgboost.XGBoostConfig(n_estimators: 'int' = 200, learning_rate: 'float' = 0.04, max_depth: 'int' = 4, min_child_weight: 'float' = 10.0, reg_lambda: 'float' = 1.0, min_samples: 'int' = 48, n_jobs: 'int' = 1, random_state: 'int' = 42)[source]#

Bases: object

Parameters:
  • n_estimators (int)

  • learning_rate (float)

  • max_depth (int)

  • min_child_weight (float)

  • reg_lambda (float)

  • min_samples (int)

  • n_jobs (int)

  • random_state (int)

n_estimators: int#
learning_rate: float#
max_depth: int#
min_child_weight: float#
reg_lambda: float#
min_samples: int#
n_jobs: int#
random_state: int#
class energy_methods.xgboost.XGBoostModel(estimator, config, feature_names, training_rows)[source]#

Bases: object

Fitted regressor, with explicit feature order and training-row count.

Parameters:
  • estimator (XGBRegressor)

  • config (XGBoostConfig)

  • feature_names (tuple[str, ...])

  • training_rows (int)

estimator: XGBRegressor#
config: XGBoostConfig#
feature_names: tuple[str, ...]#
training_rows: int#
predict(features)[source]#

Return predictions in the target unit, without implicit physical clipping.

Parameters:

features (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])

Return type:

FloatArray

to_dict()[source]#

Export native JSON model state and the exact feature contract.

Return type:

dict[str, object]

energy_methods.xgboost.fit_xgboost(features, target, *, feature_names=None, config=XGBoostConfig(n_estimators=200, learning_rate=0.04, max_depth=4, min_child_weight=10.0, reg_lambda=1.0, min_samples=48, n_jobs=1, random_state=42))[source]#

Fit supplied training rows only; no random split or holdout-based early stopping.

Parameters:
  • features (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])

  • target (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])

  • feature_names (tuple[str, ...] | None)

  • config (XGBoostConfig)

Return type:

XGBoostModel