rodrigo-arenas / Sklearn-genetic-opt

ML hyperparameters tuning and features selection, using evolutionary algorithms.
https://sklearn-genetic-opt.readthedocs.io
MIT License
286 stars 73 forks source link

How can I supress sklearn warnings when calling the GASearchCV fit method? #142

Closed JuanCamilo-R closed 9 months ago

JuanCamilo-R commented 9 months ago

Hey, I have this issue that I've not been able to solve it. Whenever I try to call the fit method of the GASearchCV class with 'precision' score, I get the 'UndefinedMetricWarning' multiple times from sklearn, I know this is due to the model and data itself that is being provided. However, I want to supress this kind of warnings or at least that appears just once. Does anyone know how can I achieve this? Thank you in advance.

rodrigo-arenas commented 9 months ago

Hi @JuanCamilo-R if you are sure this warning is not compromising the model itself, you can try suppressing it using the warnings module.

import warnings

warnings.filterwarnings('always')

You can also pass to the metric parameter instead of the word "precision", a precision metric object with a more detailed config, so you can try to remove that warning

CrypticRevenger commented 9 months ago

Please assign me, I want to do it.

rodrigo-arenas commented 9 months ago

Hi @CrypticRevenger in this case this won't be added to the package, as it's not expected to suppress warnings from other packages, this can be easily done with the snippet I provided, if you're interested, there are other couple open issues that requires some hands-on, thanks

@JuanCamilo-R I'm closing this issue for now, let me know if you have more questions