Open yuta100101 opened 1 year ago
@yuta100101 Thank you for reporting! It should be replaced with callback API.
As a temporary measure, I have set a version constraint on the installation of LightGBM. The version has been limited to LightGBM<4.0.0. I plan to address the main fix for this bug in a separate pull request.
Here is an article that may be helpful in resolving this issue. Qiita - LightGBMのearly_stoppingの仕様が変わったので、使用法を調べてみた
Not only cross_validate()
but also find_best_lgbm_parameter()
is affected, so it might be better to modify this library after Optuna's support for LightGBM 4.0.0 (Probably the PRs shown below) has been released.
Sorry for the lack of words, find_best_lgbm_parameter()
is affected by removing fobj
argument of train()
.
Thanks for publishing such a useful tool!
A few days ago, LightGBM's new version 4.0.0 has been released.
In this release,
early_stopping_rounds
argument infit()
was removed.So, functions that use
cross_validate()
such asrun_experiment
don't work. (There may be other functions that don't work, I haven't investigated yet.)Of cource, there is no probrem with versions before 3.3.5.
pytest log
``` (nyaggle) yuta100101:~/nyaggle(master =)$ pytest tests/validation/test_cross_validate.py::test_cv_lgbm ========================================================================================== test session starts =========================================================================================== platform linux -- Python 3.9.17, pytest-7.4.0, pluggy-1.2.0 rootdir: /home/yuta100101/practice/nyaggle collected 1 item tests/validation/test_cross_validate.py F [100%] ================================================================================================ FAILURES ================================================================================================ ______________________________________________________________________________________________ test_cv_lgbm ______________________________________________________________________________________________ def test_cv_lgbm(): X, y = make_classification(n_samples=1024, n_features=20, class_sep=0.98, random_state=0) X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.5, random_state=0) models = [LGBMClassifier(n_estimators=300) for _ in range(5)] > pred_oof, pred_test, scores, importance = cross_validate(models, X_train, y_train, X_test, cv=5, eval_func=roc_auc_score, fit_params={'early_stopping_rounds': 200}) tests/validation/test_cross_validate.py:52: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ estimator = [LGBMClassifier(n_estimators=300), LGBMClassifier(n_estimators=300), LGBMClassifier(n_estimators=300), LGBMClassifier(n_estimators=300), LGBMClassifier(n_estimators=300)] X_train = 0 1 2 3 4 5 6 7 8 ... 11 12... ... -0.109782 -0.412230 1.707714 -0.240937 -0.276747 0.481276 -0.278111 1.304773 -0.139538 [512 rows x 20 columns] y = 0 0 1 0 2 0 3 1 4 0 .. 507 0 508 1 509 0 510 1 511 0 Name: target, Length: 512, dtype: int64 X_test = 0 1 2 3 4 5 6 7 8 ... 11 12... ... -2.598922 -0.351561 0.233836 -1.873634 -1.089221 0.373956 -0.520939 -0.489945 2.452996 [512 rows x 20 columns] cv = KFold(n_splits=5, random_state=0, shuffle=True), groups = None, eval_func =