我的数据有点不平衡,所以我在做逻辑回归模型之前尝试做一个 SMOTE 算法。当我这样做时,我收到错误:KeyError: 'Only the Series name can be used for the key in Series dtype mappings.' 有人可以帮我弄清楚为什么吗?这是代码:
X = dummies.loc[:, dummies.columns != 'Count']
y = dummies.loc[:, dummies.columns == 'Count']
#from imblearn.over_sampling import SMOTE
os = SMOTE(random_state=0)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=0)
columns = X_train.columns
os_data_X,os_data_y=os.fit_sample(X_train, y_train) # here is where it errors
os_data_X = pd.DataFrame(data=os_data_X,columns=columns )
os_data_y= pd.DataFrame(data=os_data_y,columns=['Count'])
谢谢!