-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Updated LightGBM to 4.1 and Optuna to 3.3, and the other packages #29
Updated LightGBM to 4.1 and Optuna to 3.3, and the other packages #29
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR. Two minor things:
- can you please silent the lgb output during cv and training in
model.py
- can you please use version 4.1.0 in the
setup.py
Thanks
So I've addressed the second comment but I'm not sure its possible to address point 1 for now. I've dug into the changelog and code and I can't see anyway to suppress the message. when you look in the parameters its not really mentioned that you can use a custom objective function, although in the python API its mentioned in the notes that you can do that, but nothing about how to suppress the message. Finally in the source code the message is created when the objective function isn't the base one with no statement for overriding it. |
Thanks for your changes. Can you please open an issue on the LightGBM repo asking how to silence the output. Thanks. |
So I've just seen this issue already exists in the lightgbm repo. I'm not sure if you want the temporary work around of the custom logger class implemented? |
Does the custom logger verbose output for both .cv and .train? |
@EchoDel To keep the PR open, can you please check the open issues on the verbosity, thanks. |
Sorry for the delay. Yeh this would fix both since we register it with lgbm at the start |
@EchoDel Using the suggestion from the lightgbm-issue does not work. I am using import lightgbm as lgb
class CustomLogger:
def init(self):
self.logger = logging.getLogger('lightgbm_custom')
self.logger.setLevel(logging.ERROR)
def info(self, message):
self.logger.info(message)
def warning(self, message):
# Suppress warnings by not doing anything
pass
def error(self, message):
self.logger.error(message)
lgb.register_logger(CustomLogger()) and this gives the following. Can you please look into this. Exception ignored on calling ctypes callback function: <function _log_callback at 0x0000026D45999760>
Traceback (most recent call last):
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 205, in _log_callback
_log_native(str(msg.decode('utf-8')))
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 183, in wrapper
return func(msg)
^^^^^^^^^
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 200, in _log_native
getattr(_LOGGER, _INFO_METHOD_NAME)(msg)
File "C:\Users\maerzale\AppData\Local\Temp\ipykernel_14620\1534461007.py", line 7, in info
AttributeError: 'CustomLogger' object has no attribute 'logger'
Exception ignored on calling ctypes callback function: <function _log_callback at 0x0000026D45999760>
Traceback (most recent call last):
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 205, in _log_callback
_log_native(str(msg.decode('utf-8')))
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 183, in wrapper
return func(msg)
^^^^^^^^^
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 200, in _log_native
getattr(_LOGGER, _INFO_METHOD_NAME)(msg)
File "C:\Users\maerzale\AppData\Local\Temp\ipykernel_14620\1534461007.py", line 7, in info
AttributeError: 'CustomLogger' object has no attribute 'logger'
Exception ignored on calling ctypes callback function: <function _log_callback at 0x0000026D45999760>
Traceback (most recent call last):
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 205, in _log_callback
_log_native(str(msg.decode('utf-8')))
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 183, in wrapper
return func(msg)
^^^^^^^^^
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 200, in _log_native
getattr(_LOGGER, _INFO_METHOD_NAME)(msg)
File "C:\Users\maerzale\AppData\Local\Temp\ipykernel_14620\1534461007.py", line 7, in info
AttributeError: 'CustomLogger' object has no attribute 'logger'
Exception ignored on calling ctypes callback function: <function _log_callback at 0x0000026D45999760>
Traceback (most recent call last):
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 205, in _log_callback
_log_native(str(msg.decode('utf-8')))
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 183, in wrapper
return func(msg)
^^^^^^^^^
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 200, in _log_native
getattr(_LOGGER, _INFO_METHOD_NAME)(msg)
File "C:\Users\maerzale\AppData\Local\Temp\ipykernel_14620\1534461007.py", line 7, in info
AttributeError: 'CustomLogger' object has no attribute 'logger'
Exception ignored on calling ctypes callback function: <function _log_callback at 0x0000026D45999760>
Traceback (most recent call last):
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 205, in _log_callback
_log_native(str(msg.decode('utf-8')))
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 183, in wrapper
return func(msg)
^^^^^^^^^
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 200, in _log_native
getattr(_LOGGER, _INFO_METHOD_NAME)(msg)
File "C:\Users\maerzale\AppData\Local\Temp\ipykernel_14620\1534461007.py", line 7, in info
AttributeError: 'CustomLogger' object has no attribute 'logger'
Exception ignored on calling ctypes callback function: <function _log_callback at 0x0000026D45999760>
Traceback (most recent call last):
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 205, in _log_callback
_log_native(str(msg.decode('utf-8')))
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 183, in wrapper
return func(msg)
^^^^^^^^^
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 200, in _log_native
getattr(_LOGGER, _INFO_METHOD_NAME)(msg)
File "C:\Users\maerzale\AppData\Local\Temp\ipykernel_14620\1534461007.py", line 7, in info
AttributeError: 'CustomLogger' object has no attribute 'logger'
Exception ignored on calling ctypes callback function: <function _log_callback at 0x0000026D45999760>
Traceback (most recent call last):
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 205, in _log_callback
_log_native(str(msg.decode('utf-8')))
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 183, in wrapper
return func(msg)
^^^^^^^^^
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 200, in _log_native
getattr(_LOGGER, _INFO_METHOD_NAME)(msg)
File "C:\Users\maerzale\AppData\Local\Temp\ipykernel_14620\1534461007.py", line 7, in info
AttributeError: 'CustomLogger' object has no attribute 'logger'
Exception ignored on calling ctypes callback function: <function _log_callback at 0x0000026D45999760>
Traceback (most recent call last):
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 205, in _log_callback
_log_native(str(msg.decode('utf-8')))
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 183, in wrapper
return func(msg)
^^^^^^^^^
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 200, in _log_native
getattr(_LOGGER, _INFO_METHOD_NAME)(msg)
File "C:\Users\maerzale\AppData\Local\Temp\ipykernel_14620\1534461007.py", line 7, in info
AttributeError: 'CustomLogger' object has no attribute 'logger'
Exception ignored on calling ctypes callback function: <function _log_callback at 0x0000026D45999760>
Traceback (most recent call last):
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 205, in _log_callback
_log_native(str(msg.decode('utf-8')))
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 183, in wrapper
return func(msg)
^^^^^^^^^
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 200, in _log_native
getattr(_LOGGER, _INFO_METHOD_NAME)(msg)
File "C:\Users\maerzale\AppData\Local\Temp\ipykernel_14620\1534461007.py", line 7, in info
AttributeError: 'CustomLogger' object has no attribute 'logger'
Exception ignored on calling ctypes callback function: <function _log_callback at 0x0000026D45999760>
Traceback (most recent call last):
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 205, in _log_callback
_log_native(str(msg.decode('utf-8')))
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 183, in wrapper
return func(msg)
^^^^^^^^^
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 200, in _log_native
getattr(_LOGGER, _INFO_METHOD_NAME)(msg)
File "C:\Users\maerzale\AppData\Local\Temp\ipykernel_14620\1534461007.py", line 7, in info
AttributeError: 'CustomLogger' object has no attribute 'logger'
Exception ignored on calling ctypes callback function: <function _log_callback at 0x0000026D45999760>
Traceback (most recent call last):
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 205, in _log_callback
_log_native(str(msg.decode('utf-8')))
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 183, in wrapper
return func(msg)
^^^^^^^^^
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 200, in _log_native
getattr(_LOGGER, _INFO_METHOD_NAME)(msg)
File "C:\Users\maerzale\AppData\Local\Temp\ipykernel_14620\1534461007.py", line 7, in info
AttributeError: 'CustomLogger' object has no attribute 'logger'
Exception ignored on calling ctypes callback function: <function _log_callback at 0x0000026D45999760>
Traceback (most recent call last):
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 205, in _log_callback
_log_native(str(msg.decode('utf-8')))
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 183, in wrapper
return func(msg)
^^^^^^^^^
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 200, in _log_native
getattr(_LOGGER, _INFO_METHOD_NAME)(msg)
File "C:\Users\maerzale\AppData\Local\Temp\ipykernel_14620\1534461007.py", line 7, in info
AttributeError: 'CustomLogger' object has no attribute 'logger'
Exception ignored on calling ctypes callback function: <function _log_callback at 0x0000026D45999760>
Traceback (most recent call last):
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 205, in _log_callback
_log_native(str(msg.decode('utf-8')))
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 183, in wrapper
return func(msg)
^^^^^^^^^
File "C:\Users\maerzale\.virtualenvs\LightGBMLSS-8W0JA8W6\Lib\site-packages\lightgbm\basic.py", line 200, in _log_native
getattr(_LOGGER, _INFO_METHOD_NAME)(msg)
File "C:\Users\maerzale\AppData\Local\Temp\ipykernel_14620\1534461007.py", line 7, in info
AttributeError: 'CustomLogger' object has no attribute 'logger' |
This suppresses the messages for lightgbm version 4.1
I think this push has got the custom logger working. There are alot of other packages which have been updated, particularly torch which had an issues in 2.1.0 and 2.0.1 which I could wrap into this PR is you want. |
@EchoDel Is the custom logger working now? Haven't tested it yet |
Yep, the logger suppresses all the warning messages |
Yes please, thanks. The updated packages are "lightgbm~=4.1.0",
"torch~=2.1.1",
"pyro-ppl~=1.8.6",
"optuna~=3.4.0",
"properscoring~=0.1",
"scikit-learn~=1.3.2",
"numpy~=1.26.2",
"pandas~=2.1.3",
"plotnine~=0.12.4",
"scipy~=1.11.4",
"seaborn~=0.13.0",
"tqdm~=4.66.1",
"matplotlib~=3.8.2",
"ipython~=8.18.1", |
@EchoDel Thanks for updating the dependencies. Can you please fix the remaining comments so that I can merge the PR. Thanks |
The outstanding requests should be done. |
Welcome to Codecov 🎉Once merged to your default branch, Codecov will compare your coverage reports and display the results in this comment. Thanks for integrating Codecov - We've got you covered ☂️ |
lightgbmlss/model.py
Outdated
@@ -263,9 +265,9 @@ def cv(self, | |||
self.set_params(params) | |||
self.set_init_score(train_set) | |||
|
|||
params['objective'] = self.dist.objective_fn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not needed if moved to set_params
@@ -389,13 +391,13 @@ def objective(trial): | |||
callbacks=[pruning_callback, early_stopping_callback], | |||
seed=seed, | |||
) | |||
|
|||
print(lgblss_param_tuning) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need it?
Mainly updated LightGBM to the more recent 4.0 release, although optuna was an easy update as well.
My company expects packages to update to the major version before releasing anything.
I ensured that all the test suite ran before submitting the PR