sklearn: Turning off warnings(SkLearning:关闭警告)
问题描述
当我使用单列pythonpandas
DataFrame
(不是Series
对象)调整sklearn
的LogisticRegression
时,收到以下警告:
/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:关闭警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!