消除来自 scikit-learn 的警告 [英] Eliminating warnings from scikit-learn

查看:57
本文介绍了消除来自 scikit-learn 的警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在教学时忽略所有包的警告,但 scikit-learn 似乎可以解决使用 warnings 包来控制这一点.例如:

I would like to ignore warnings from all packages when I am teaching, but scikit-learn seems to work around the use of the warnings package to control this. For example:

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:

我是否错误地使用了这个模块,或者 sklearn 做了一些它不应该做的事情?

Am I using this module incorrectly, or is sklearn doing something its not supposed to?

推荐答案

sklearn 强制警告.

我开始在 main.py 的顶部使用它:

I started using this at the top of main.py:

def warn(*args, **kwargs):
    pass
import warnings
warnings.warn = warn

#... import sklearn stuff...

这篇关于消除来自 scikit-learn 的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆