quantlab.model.predefined.catboost_model.CatBoostRegressor#

class quantlab.model.predefined.catboost_model.CatBoostRegressor(config)[source]#

Bases: QlibLibraryHead

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

The training target is Qlib’s CSRankNorm (training_target "cs_rank"); NaN features are CatBoost’s missing values. The model fits with the validation rows as its eval_set and use_best_model=True, stopping after early_stopping_patience (50) rounds without a better validation RMSE. task_type is "GPU" when CatBoost sees a GPU, as in Qlib, unless set. Every other hyperparameter goes to CatBoost over CATBOOST_ALPHA158, Qlib’s Alpha158 benchmark values: loss_function "RMSE", learning_rate 0.0421, subsample 0.8789, max_depth 6, num_leaves 100, thread_count 20, grow_policy "Lossguide", bootstrap_type "Poisson" and iterations 1000.

Known difference from Qlib’s implementation: CatBoost accepts the benchmark’s Poisson bootstrap only on the GPU, so on the CPU it becomes Bernoulli with the same subsample (logged), where Qlib’s config fails.

Parameters:
configModelConfig

Factors, one label, dates and hyperparameters.

Raises:
ValueError

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

Examples

>>> head = CatBoostRegressor(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={"task_type": "CPU", "iterations": 50},
... )).collect()
>>> head.train().name
'CatBoostRegressor_total.joblib'
DEFAULTS = {'bootstrap_type': 'Poisson', 'grow_policy': 'Lossguide', 'iterations': 1000, 'learning_rate': 0.0421, 'loss_function': 'RMSE', 'max_depth': 6, 'num_leaves': 100, 'subsample': 0.8789, 'thread_count': 20}#

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