quantlab.model.predefined.lgbm.LGBMRegressor#

class quantlab.model.predefined.lgbm.LGBMRegressor(config)[source]#

Bases: QlibLibraryHead

Qlib’s LightGBM on the rows of the cross-sectional rank target.

The training target is Qlib’s CSRankNorm (training_target "cs_rank"); NaN features are LightGBM’s missing values. lgb.train evaluates the training and validation sets every round and stops after early_stopping_patience (50) rounds without a better validation loss; the Booster predicts with its best round. Every other hyperparameter goes to lgb.train over LGBM_ALPHA158, Qlib’s Alpha158 benchmark values: objective "mse", colsample_bytree 0.8879, learning_rate 0.2, subsample 0.8789 (without bagging_freq, so it samples nothing, as in Qlib), lambda_l1 205.6999, lambda_l2 580.9768, max_depth 8, num_leaves 210, num_threads 20, and num_boost_round 1000.

The per-round losses go to the tracking run, and the best round to its summary.

Parameters:
configModelConfig

Factors, one label, dates and hyperparameters.

Raises:
ValueError

At training, if the model has more than one label.

Examples

>>> head = LGBMRegressor(ModelConfig(
...     factors=[factor], labels=[label], model_save_dir="checkpoints",
...     factor_data_strategy="read", label_data_strategy="read",
...     train_start="2024-01-01", train_end="2024-05-31",
...     test_start="2024-06-01", test_end="2024-07-18",
...     hyperparameters={"num_threads": 4},
... )).collect()
>>> head.train().name
'LGBMRegressor_total.joblib'
DEFAULTS = {'colsample_bytree': 0.8879, 'lambda_l1': 205.6999, 'lambda_l2': 580.9768, 'learning_rate': 0.2, 'max_depth': 8, 'num_boost_round': 1000, 'num_leaves': 210, 'num_threads': 20, 'objective': 'mse', 'subsample': 0.8789, 'verbosity': -1}#

The library’s parameters, Qlib’s benchmark values.