首页 > 解决方案 > 在 r 中执行过采样操作时出错

问题描述

我正在研究一个机器学习模型(分类),其中我的数据集不平衡,我想通过使用 R 中“不平衡”包中的 oversample() 函数来平衡它。

下面是用于过采样的代码,其中“Final.Status”是我的响应变量,它是一个因子数据类型。

training <- na.omit(training)

training.oversamp <- oversample(training,method = "SMOTE",classAttr = 'Final.Status')

但是在这样做时,我遇到了以下错误:

Error in dataset[, classAttr] == c : 
  comparison of these types is not implemented
In addition: Warning message:
In which(dataset[, classAttr] == c) :
  Incompatible methods ("Ops.data.frame", "Ops.factor") for "=="

出于好奇,任何人都可以简要介绍 oversample() 函数中使用的不同方法以及常用的方法。

标签: rmachine-learningoversamplingsmote

解决方案


推荐阅读