Y出现ravel的问题 解决

出现:

/Users/wangchuang/anaconda3/lib/python3.6/site-packages/sklearn/utils/validation.py:547: 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)
通过查询,解决方法如下,

from imblearn.over_sampling import SMOTE # 导入SMOTE算法模块
# 处理不平衡数据
sm = SMOTE(random_state=42) # 处理过采样的方法
X, y = sm.fit_sample(X, y.values.ravel())

posted @ 2019-03-18 16:58  詹岩鹏  阅读(3014)  评论(0编辑  收藏  举报