LightGBM | LightGBMError: Check failed
Вот мой код, использующий LightGBM:
LGBM = LGBMClassifier()
LGBM_RS = RandomizedSearchCV(LGBM, {"boosting_type": ["gbdt", "dart", "rf"],
"max_depth": [int(x) for x in np.linspace(10,110,num=11)] + [-1],
'n_estimators': [int(x) for x in np.linspace(start=10,stop=300,num=10)]},
scoring="recall",
random_state=1)
LGBM_RS.fit(X_train, y_train)
При выполнении выводится следующая информация, но при этом код отрабатывает:
/usr/local/lib/python3.10/dist-packages/sklearn/model_selection/_validation.py:378: FitFailedWarning:
25 fits failed out of a total of 50.
The score on these train-test partitions for these parameters will be set to nan.
If these failures are not expected, you can try to debug them by setting error_score='raise'.
Below are more details about the failures:
--------------------------------------------------------------------------------
25 fits failed with the following error:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/sklearn/model_selection/_validation.py", line 686, in _fit_and_score
estimator.fit(X_train, y_train, **fit_params)
File "/usr/local/lib/python3.10/dist-packages/lightgbm/sklearn.py", line 1142, in fit
super().fit(
File "/usr/local/lib/python3.10/dist-packages/lightgbm/sklearn.py", line 842, in fit
self._Booster = train(
File "/usr/local/lib/python3.10/dist-packages/lightgbm/engine.py", line 255, in train
booster = Booster(params=params, train_set=train_set)
File "/usr/local/lib/python3.10/dist-packages/lightgbm/basic.py", line 3204, in __init__
_safe_call(_LIB.LGBM_BoosterCreate(
File "/usr/local/lib/python3.10/dist-packages/lightgbm/basic.py", line 242, in _safe_call
raise LightGBMError(_LIB.LGBM_GetLastError().decode('utf-8'))
lightgbm.basic.LightGBMError: Check failed: (config->bagging_freq > 0 && config->bagging_fraction < 1.0f && config->bagging_fraction > 0.0f) || (config->feature_fraction < 1.0f && config->feature_fraction > 0.0f) at /__w/1/s/lightgbm-python/src/boosting/rf.hpp, line 36 .
warnings.warn(some_fits_failed_message, FitFailedWarning)
/usr/local/lib/python3.10/dist-packages/sklearn/model_selection/_search.py:952: UserWarning: One or more of the test scores are non-finite: [ nan nan 0.93047595 0.96121687 0.94985693 0.96974636
0.92165832 nan nan nan]
warnings.warn(
Почему так происходит? В ошибке говорится что-то про bagging_fraction
и bagging_freq
, но я их даже не использую в RandomizedSearchCV()
.