在用SMOTE算法模块进行过采样(oversampling)时,pandas导入训练集合特征和label。


from imblearn.over_sampling import SMOTE # 导入SMOTE算法模块
# 处理不平衡数据
sm = SMOTE(random_state=122)    # 处理过采样的方法
X, y = sm.fit_sample(X, y)
/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())

 

相关文章:

  • 2022-01-22
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
  • 2021-10-14
  • 2021-06-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-05
  • 2022-12-23
  • 2021-04-19
  • 2021-12-28
  • 2022-12-23
相关资源
相似解决方案