I add my experience here because some users seems not to be able to silence the warnings even if they use the warnings.filterwarnings('ignore')
solution suggested by @sreeram-tp.
If this is your case and you are executing a GridSearchCV
or RandomizedSearchCV
with parallel jobs (i.e. n_jobs
paramether not equal to 1), this happens because the jobs spawned by joblib
do not inherit the same warning filter set in the current job. For more information consult the answer by @caseygrun.
In my case to fix this behavior I had to apply both the solutions:
# Removes warnings in the current job
warnings.filterwarnings("ignore")
# Removes warnings in the spawned jobs
os.environ['PYTHONWARNINGS']='ignore'
Please, note that setting only the os environmental variable is not enough. Both the commands are needed.
EDIT: I know that the case of the question is related to the f1_score metric, but unfortunately other threads that may be more appropriate are closed. Since I do not have enough points to comment I have to add this answer under a similar question.