models.forecaster_recursive_lgbm_full

models.forecaster_recursive_lgbm_full

LGBM forecaster with real Bayesian tuning and SHAP.

This module provides ForecasterRecursiveLGBMFull, which combines the LightGBM forecaster from spotforecast2-safe with Bayesian hyperparameter optimisation (Optuna) and SHAP-based feature importance from ForecasterRecursiveModelFull.

Examples

from spotforecast2.models import ForecasterRecursiveLGBMFull

model = ForecasterRecursiveLGBMFull(iteration=0)
assert model.name == "lgbm"
assert model.forecaster is not None
assert model.n_trials == 10
print(f"name={model.name}, n_trials={model.n_trials}, iteration={model.iteration}")
name=lgbm, n_trials=10, iteration=0

Classes

Name Description
ForecasterRecursiveLGBMFull LGBM forecaster with real Bayesian tuning and SHAP.

ForecasterRecursiveLGBMFull

models.forecaster_recursive_lgbm_full.ForecasterRecursiveLGBMFull(
    iteration,
    lags=12,
    **kwargs,
)

LGBM forecaster with real Bayesian tuning and SHAP.

Inherits the LightGBM forecaster initialisation from ForecasterRecursiveLGBM (spotforecast2-safe) and adds the real tune() and get_global_shap_feature_importance() from ForecasterRecursiveModelFull.

The MRO ensures that tune() and SHAP methods resolve from ForecasterRecursiveModelFull, while the LightGBM-specific __init__ (estimator wiring) comes from ForecasterRecursiveLGBM.

Parameters

Name Type Description Default
iteration int Training iteration index (0-based). required
lags int Number of lag features to use. 12
**kwargs Any Forwarded to parent classes (e.g., n_trials, predict_size, train_size). {}

Examples

from spotforecast2.models import ForecasterRecursiveLGBMFull

model = ForecasterRecursiveLGBMFull(iteration=0)
assert model.name == "lgbm"
assert model.forecaster is not None
assert model.n_trials == 10
assert model.iteration == 0
print(f"name={model.name}, n_trials={model.n_trials}, iteration={model.iteration}")
print(f"tune callable: {callable(model.tune)}")
print(f"shap callable: {callable(model.get_global_shap_feature_importance)}")
name=lgbm, n_trials=10, iteration=0
tune callable: True
shap callable: True