r - 在 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() 函数中使用的不同方法以及常用的方法。
解决方案
推荐阅读
- python - 在 pycharm ImportError: DLL load failed: 找不到指定的模块。导入人脸识别时
- c# - C# 数据表组,选择和求和
- ios - 如何使用 unarchivedObjectOfClass:fromData:error: 取消归档数据?
- java - 如何用 Jackson 解析大的嵌套 JSON 文件?
- dart - 如何在 Flutter 中将 Visual Studio Emulator 与 VScode 连接起来?
- c# - 创建一个循环,要求输入的第一个字母在上,其他字母在下
- javascript - 本地资产大量涌入
- r - 始终以分钟为单位获取时差
- algorithm - 使用 dincis 算法和 ford fulkerson 解决最大流量问题的最佳算法是什么?
- powershell - 如何将构建参数/环境变量传递给powershell管道