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发布链接。
相关文章