本文介绍了RandomUnderSampler'对象没有属性'fit_resample'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用imblearn
中的RandomUnderSampler
,但是出现以下错误.有任何想法吗?谢谢
I am using RandomUnderSampler
from imblearn
, but I get the following error. Any ideas? Thanks
from imblearn.under_sampling import RandomUnderSampler
print('Initial dataset shape %s' % Counter(y.values.squeeze()))
rus = RandomUnderSampler(random_state=42)
X_undersampled, y_undersampled = rus.fit_resample(X, y)
y_undersampled = y_undersampled.squeeze()
输出:
Initial dataset shape Counter({0: 2499739, 1: 1558})
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-18-4fe9dcfbd68e> in <module>
1 print('Initial dataset shape %s' % Counter(y.values.squeeze()))
2 rus = RandomUnderSampler(random_state=42)
----> 3 X_undersampled, y_undersampled = rus.fit_resample(X, y)
4 y_undersampled = y_undersampled.squeeze()
5
AttributeError: 'RandomUnderSampler' object has no attribute 'fit_resample'
我正在使用的主要库:
imbalanced-learn==0.3.3
pandas==0.24.2
numpy==1.15.4
scikit-learn==0.19.2
推荐答案
方法fit_resample
最近被引入到imbalanced-learn
API中.更新imbalanced-learn
或改用fit_sample
.
The method fit_resample
was introduced lately to imbalanced-learn
API. Either update imbalanced-learn
or use fit_sample
instead.
这篇关于RandomUnderSampler'对象没有属性'fit_resample'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!