【问题标题】:How to undersample/oversample more than two classes' dataset using "imblearn" library in Python?如何在 Python 中使用“imblearn”库对两个以上类的数据集进行欠采样/过采样?
【发布时间】:2020-09-19 03:22:06
【问题描述】:

我正在使用“imblearn”库进行欠采样。我的数据集中有四个类,每个类有 20、30、40 和 50 个数据(因为它是一个不平衡的类)。

但是当我尝试使用“fit_resample(X, y)”对数据集进行欠采样时,它只会对第一个和最后一个类进行欠采样。

有什么方法可以使用“imblearn”对所有四个类进行欠采样?

必要代码:

undersample = RandomUnderSampler(sampling_strategy='majority')
X_over, y_over = undersample.fit_resample(X, y)

【问题讨论】:

    标签: python python-3.x python-2.7 imbalanced-data imblearn


    【解决方案1】:

    问题已解决,设置 smapling_strategy='all'

    【讨论】:

      猜你喜欢
      • 2023-03-23
      • 2018-01-13
      • 2022-09-26
      • 2020-09-06
      • 2020-04-28
      • 1970-01-01
      • 2023-01-29
      • 2019-09-03
      • 2017-06-08
      相关资源
      最近更新 更多