SkLearning:关闭警告 [英] sklearn: Turning off warnings

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

问题描述

当我使用单列pythonpandasDataFrame(不是Series对象)调整sklearnLogisticRegression时,收到以下警告:

/Library/Python/2.7/site-packages/sklearn/preprocessing/label.py:125:         
DataConversionWarning: A column-vector y was passed when a 1d array was 
expected. Please change the shape of y to (n_samples, ), for example using 
ravel().
y = column_or_1d(y, warn=True)

我知道我可以很容易地在代码中显示此警告,但如何关闭这些警告?

推荐答案

如发布的here

with warnings.catch_warnings():
    warnings.simplefilter("ignore")
    # Do stuff here

感谢上述Andreas发布链接。

这篇关于SkLearning:关闭警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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