LightGBM: Lightgbm trains much slower than catboost.
On Ubuntu 22.04.2 LTS,python version 3.11.4,lightgbm 4.3.0。 Data size is 3000. params
{
"boosting_type": "gbdt",
"objective": "binary",
"verbose": -1,
"n_jobs": -1,
"device": "cpu",
"random_state": 1,
"metric": "None",
"learning_rate": 0.03,
}
feval:
def weighted_f1_score(preds, train_data):
labels = train_data.get_label()
preds_binary = (preds > 0.5).astype(int)
f1 = f1_score(labels, preds_binary, average="weighted")
return "weighted_f1_score", f1, True
I use several categorical_features.
lightgbm.train(
params=params,
train_set=train_dataset,
num_boost_round=iterations,
feval=feval,
categorical_feature=current_cat_feature,
callbacks=[ lightgbm.early_stopping(50, first_metric_only=False),lightgbm.log_evaluation(period=20, show_stdv=True),],
)
I need 5 minutes to train, much slower than catboost.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (3 by maintainers)
Hey @fengshansi, thanks for using LightGBM. Unfortunately, this isn’t enough information, we’d also need the following:
For 3,000 samples 5 minutes sounds like a lot so I’m guessing your custom metric is being the bottleneck here but it’s very hard to tell with just this information.
可能是 python 版本和 lightgbm 版本的问题。我自己使用 python 3.11.9 和 lightgbm 4.3.0 时需要跑半小时以上,但是使用 python 3.10.13 和 lightgbm 4.1.0 只需要几分钟。
Here is code and data https://github.com/fengshansi/lgbm_compare.
Without data and working code, I fear we are stuck here.