Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Can't suppress warning messages through standard python methods #255

Closed
RNarayan73 opened this issue Nov 7, 2022 · 4 comments
Closed

Can't suppress warning messages through standard python methods #255

RNarayan73 opened this issue Nov 7, 2022 · 4 comments

Comments

@RNarayan73
Copy link

Hello,

I am getting warning messages below even with verbose=0 or 1:

2022-11-07 12:04:56,052 INFO tensorboardx.py:267 -- Removed the following hyperparameter values when logging to tensorboard: {'enc__target': BayesianTargetEncoder(columns=['Symbol', 'CandleType', 'h1CandleType1',
'h2CandleType1'],
prior_weight=3, suffix=''), 'enc__time__cyclicity': CyclicalFeatures(drop_original=True)}
(_Trainable pid=39836) C:\Anaconda3\envs\skl_py310\lib\site-packages\category_encoders\target_encoder.py:92: FutureWarning: Default parameter min_samples_leaf will change in version 2.6.See scikit-learn-contrib/category_encoders#327
(_Trainable pid=39836) warnings.warn("Default parameter min_samples_leaf will change in version 2.6."
(_Trainable pid=39836) C:\Anaconda3\envs\skl_py310\lib\site-packages\category_encoders\target_encoder.py:97: FutureWarning: Default parameter smoothing will change in version 2.6.See scikit-learn-contrib/category_encoders#327

which I have tried to suppress using standard python approaches like:

from warnings import filterwarnings
filterwarnings(action='ignore', category=FutureWarning)   # works for optuna but not ray
filterwarnings(action='ignore', module='target_encoder.py', lineno=92)
filterwarnings(action='ignore', module='target_encoder.py', lineno=97)
filterwarnings(action='ignore', module='tensorboardx.py', lineno=267)

Any suggestions on how to resolve this?

Regards
Narayan

@Yard1
Copy link
Member

Yard1 commented Nov 7, 2022

The issue here is that the changes to the environment (filterwarnings in your case) are not propagated to the Trainable Ray Actors, which run in separate Python processes. Ray will capture all stdout and stderr from those and pipe it to the driver process.

You can initialise Ray before using tune-sklearn with ray.init(log_to_driver=False) argument, which will prevent any output from the Actors from showing up. This is probably not what you want if using Ray for other purposes, but if you are only using it for tune-sklearn, it should be sufficient.

@RNarayan73
Copy link
Author

Thanks,
Does this mean that the verbose argument is irrelevant? I want warning messages to appear to know if something is wrong, but having acknowledged them, I would like to shut specific ones down.
Sounds like that can't be done with tune-sklearn as it stand?
Narayan

@Yard1
Copy link
Member

Yard1 commented Nov 8, 2022

The verbose argument concerns the verbosity of Tune's output. Unfortunately, I don't think there is an easy way of supressing warnings in Actors with tune-sklearn. Would you be interesting in contributing that feature? I am happy to offer guidance.

@RNarayan73
Copy link
Author

@Yard1 thanks for your reply.
I am not very familiar with the architecture of ray itself and am only using it due to tune-sklearn's api that allows me to use it instead of or alongside alternative hyperparameter search algorithms in my current project.
Appreciate you offer of guidance and when I do delve deeper into ray down the line, I'll be glad to take up your offer.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants