首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >python错误中的resample()

python错误中的resample()
EN

Stack Overflow用户
提问于 2017-09-22 21:36:04
回答 1查看 1K关注 0票数 0

我正在拾取Python....trying以使用重采样,并在引用https://elitedatascience.com/imbalanced-classes时出现以下错误

代码语言:javascript
复制
from sklearn.utils import resample

df_majority = df[df.balance==0]
df_minority = df[df.balance==1]
#Upsample minority class
df_minority_upsampled = resample(df_minority, 
                                 replace=True,     # sample with replacement
                                 n_samples=576,    # to match majority class
                                 random_state=123) # reproducible results
=================
Error:
Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
  File "C:\Anaconda3\lib\site-packages\sklearn\utils\__init__.py", line 253, in resample
    max_n_samples, n_samples))
ValueError: Cannot sample 576 out of arrays with dim 49

感谢任何help...pointers..谢谢

附言:我正在使用齐柏林飞艇笔记本来尝试这些。

EN

回答 1

Stack Overflow用户

发布于 2017-09-22 21:53:19

我很确定这与你的sklearn版本有关。assert sklearn.__version__ >= 0.18可能会以现在的方式导致异常。:)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46366128

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档