Chr*_*eck 54 python warnings scikit-learn
我想在教学时忽略所有包装中的警告,但是scikit-learn似乎可以解决使用warnings包来控制它的问题.例如:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
from sklearn import preprocessing
/usr/local/lib/python3.5/site-packages/sklearn/utils/fixes.py:66: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() instead
if 'order' in inspect.getargspec(np.copy)[0]:
/usr/local/lib/python3.5/site-packages/sklearn/utils/fixes.py:358: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() instead
if 'exist_ok' in inspect.getargspec(os.makedirs).args:
Run Code Online (Sandbox Code Playgroud)
我是否错误地使用了这个模块,或者是否正在做一些不应该做的事情?
jos*_*805 68
它让我极为恼火,sklearn 强制警告.
我开始在main.py的顶部使用它:
def warn(*args, **kwargs):
pass
import warnings
warnings.warn = warn
#... import sklearn stuff...
Run Code Online (Sandbox Code Playgroud)
Zak*_*kum 57
他们在2013年改变了警告政策.您可以使用以下内容忽略警告(也是特定类型):
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
Run Code Online (Sandbox Code Playgroud)
//编辑:在下面的评论中,Reed Richards指出,the filterwarnings call needs to be in the file that calls the function that gives the warning.
我希望这可以帮助那些遇到此解决方案问题的人.
| 归档时间: |
|
| 查看次数: |
34410 次 |
| 最近记录: |