xgboost: XGBoost 2.0 doesn't support Optuna Pruning Callback
In older version XGBoost, we can use Optuna prunning callback (see example code here). Like code below:
Now in XGBoost2.0 train() function, Callback has to be TainingCallback (https://xgboost.readthedocs.io/en/stable/python/python_api.html#callback-api), so we can’t use Optuna pruning on XGboost any more…
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Comments: 15 (3 by maintainers)
@hanhanwu Thank you for providing the Python snippet. I was able to reproduce the error.
Diagnosis The current version of Optuna has a bug that made
XGBoostPruningCallbackincompatible with XGBoost 2.0. The bug was fixed in this pull request: https://github.com/optuna/optuna/pull/4921. Unfortunately, the fix is not yet part of the latest release of Optuna (3.3.0).Solution For now, you can install the development version of Optuna in your Python environment:
This should fix the error.
Thank you guys!
You guys are still very young, having lots of future potentials. I honestly think what you’re doing here has more meaning than you think now. Don’t plan to change you opinions, as a gift, want to share 2 stories:
These people all inspired me a lot in work. Sometimes, it’s just this type of small things, Q&A made a difference. I wonder 5 years later, how are you guys going to think 😃 Anyway, thank you all!
Apologies for closing the issue prematurely. Next time, we won’t close issues until they are resolved. Also I am sorry that I rushed my 2nd response (https://github.com/dmlc/xgboost/issues/9608#issuecomment-1734600728). It was technically correct but not very helpful. I will try to do better next time.
Mostly because we are limited in our time. Like other open source projects, we try to provide support at the best effort basis. (Of course, this does not excuse closing this issue prematurely. I am just providing a context here.)
Sure, apologies for the inconvenience. Sometimes I’m too used to these types of issues and assume that people will get the answer by looking into some of the code, hence the referenced link to optuna. There’s definitely room for improvement.
It’s mostly open source project’s issues, you see, it’s not a product, and we are not customer service. I started contribution as a student in school. We expect the community to cooperate and help given that xgboost is a library and users are developers themselves, at least try to give some quick debugging to the issues at hand, it’s not unusual for me to ask others do they want to open a PR.
Feel free to reopen the issue if the answer is unsatisfying, we can provide further assistance at best effort.
You need the latest optuna: https://github.com/optuna/optuna/blob/a920a91e4e5a32ade707f3e9819fff0f96cc7946/optuna/integration/xgboost.py#L16