sergioburdisso / pyss3

A Python package implementing a new interpretable machine learning model for text classification (with visualization tools for Explainable AI :octocat:)
https://pyss3.readthedocs.io
MIT License
336 stars 44 forks source link

Substantial print pollution when optimising for hyperpameters #1

Closed LemurPwned closed 4 years ago

LemurPwned commented 4 years ago

Hello, while I was trying to optimise for hyperparameters I have found that there is little I could do to avoid having a large printout to stdout.

I tried to mute this by doing the following:

import pyss3
pyss3.Print.set_quiet(True)

but besides, it is also tqdm that produces progress bars, hence I propose propagating Print.__quiet__to tqdm's disable parameter, for example:

tqdm(..., disable=Print.__quiet__)

Thanks :) Keep up the good work!

sergioburdisso commented 4 years ago

Hi @LemurPwned! Again, thanks for the valuable feedback, taking into account your suggestions I've completely redesigned the way in which PySS3 handles verbosity levels. Below I'll paste the message of the commit (216be41) that solved this issue:


In response to Issue #1, the way in which PySS3 handled the level of verbosity was redesigned in order to give the user greater control through a clearer interface. Now PySS3 supports the following 3 levels of verbosity:

Besides, now the following built-in constants can also be used to refer to these 3 values: VERBOSITY.QUIET, VERBOSITY.NORMAL, and VERBOSITY.VERBOSE, respectively. In addition, a set_verbosity function has been added to the main module, for the user to change the verbosity level. For example, let's suppose we want to set the verbosity level to 'quiet', then we could use:

import pyss3
...
pyss3.set_verbosity(0)
...

or, equivalently:

import pyss3
from pyss3 import VERBOSITY
...
pyss3.set_verbosity(VERBOSITY.QUIET)
...

To carry out this update, the Print class was partially redesigned, and therefore, as it can be seen, the source code of all the modules had to be modified as well (to be compatible with the new Print design).

[*] Note that, unlike before, PySS3 will now, by default, only show progress bars (plus warning or error messages).


I think that this new interface is much clearer and the user can use it without "being aware" of what's "under the hood" (that is, the "Print" class), which I think is great.

Anyway, I was working on a new version release (0.4.0) when I read your issue, so I decided to pospone its release and add this modification to the new version. This new release will improve and incorporate new features, such as an explicit support for multi-label classification and a method for the user to automatically extract "useful insights" (relevant text fragments) from documents, I'll release this new version today, so you'll be able to update your code after updating the package (I'll notify you as soon as it is released).

:D

Thank you very much for your useful ideas and feedback, buddy :+1:

sergioburdisso commented 4 years ago

(Version 0.4.0 has already been released, :bird: now is wild and free? :stuck_out_tongue:)