在用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())