python用RandomUnderSampler库下采样的时候,报的错
原代码:
from collections import Counter
from imblearn.under_sampling import RandomUnderSampler
train = pd.read_csv('./data/0504_ftr.csv')
test = pd.read_csv('./data/0504_fte.csv')
y = train['label']-1
del train['label']
y_test = test['label']-1
del test['label']
rus = RandomUnderSampler(random_state=0)
X_resampled, y_resampled = rus.fit_sample(train, y)
print(sorted(Counter(y_resampled).items()))
修改,把fit_sample()改成fit_resample()
如下:
from collections import Counter
from imblearn.under_sampling import RandomUnderSampler
train = pd.read_csv('./data/0504_ftr.csv')
t