跑步时如何使以下警告静音
GridSearchCV(model, params, cv=10, scoring='precision', verbose=1, n_jobs=20, refit=True)
?
/opt/dev/myenv/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1531: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 due to no predicted samples. Use `zero_division` parameter to control this behavior.
我尝试过但没有成功:
import os, warnings
warnings.simplefilter("ignore")
warnings.filterwarnings("ignore")
with warnings.catch_warnings():
warnings.simplefilter("ignore")
os.environ["PYTHONWARNINGS"] = "ignore"