hli*_*117 13 python warnings pandas scikit-learn
当我安装sklearnS" LogisticRegression使用1列蟒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)
Run Code Online (Sandbox Code Playgroud)
我知道我可以在我的代码中轻松地宣传此警告,但是如何关闭这些警告呢?
小智 19
你可以用这个:
import warnings
from sklearn.exceptions import DataConversionWarning
warnings.filterwarnings(action='ignore', category=DataConversionWarning)
Run Code Online (Sandbox Code Playgroud)
hli*_*117 11
张贴在这里,
with warnings.catch_warnings():
warnings.simplefilter("ignore")
# Do stuff here
Run Code Online (Sandbox Code Playgroud)
感谢上面的Andreas发布链接.
| 归档时间: |
|
| 查看次数: |
19580 次 |
| 最近记录: |