quantlab.model.predefined.lgbm.LGBMRegressor#
- class quantlab.model.predefined.lgbm.LGBMRegressor(config)[source]#
Bases:
QlibLibraryHeadQlib’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.trainevaluates the training and validation sets every round and stops afterearly_stopping_patience(50) rounds without a better validation loss; the Booster predicts with its best round. Every other hyperparameter goes tolgb.trainoverLGBM_ALPHA158, Qlib’s Alpha158 benchmark values:objective"mse",colsample_bytree0.8879,learning_rate0.2,subsample0.8789 (withoutbagging_freq, so it samples nothing, as in Qlib),lambda_l1205.6999,lambda_l2580.9768,max_depth8,num_leaves210,num_threads20, andnum_boost_round1000.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.