python - RandomUnderSampler' 对象没有属性 'fit_resample'
问题描述
我正在使用RandomUnderSampler
from imblearn
,但出现以下错误。有任何想法吗?谢谢
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
改用。
推荐阅读
- python - numpy:内容到索引,索引到内容
- vba - 从网站上抓取数据的问题
- oracle - Statspack 报告大量执行,高于 V$sql 中的总数
- raspberry-pi - restbed make install in raspberry-pi undefined reference to dlopen dlclose
- java - 在 maven-compiler-plugin 上将 Maven 从 Java 9 迁移到 Java 10 失败
- php - 在foreach循环php期间检查数组值的变化
- python - 在具有增量名称的数据框列上应用公式
- javascript - 大写输入将光标移动到末尾
- javascript - 使用 Rotativa 将 Google 图表渲染成 pdf 格式
- iis - 如何删除 IIS 规则中的子文件夹?