gpt4 book ai didi

python - sklearn : Turning off warnings

转载 作者:太空狗 更新时间:2023-10-29 17:54:27 26 4
gpt4 key购买 nike

当我使用 1 列 python pandas DataFrame(不是Series 对象),我收到此警告:

/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)

我知道我可以很容易地在我的代码中发出这个警告,但我怎样才能关闭这些警告?

最佳答案

你可以使用这个:

import warnings
from sklearn.exceptions import DataConversionWarning
warnings.filterwarnings(action='ignore', category=DataConversionWarning)

关于python - sklearn : Turning off warnings,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29086398/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com