- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 R
的 randomForest
包来训练分类模型。为了将它与其他分类器进行比较,我需要一种方法来显示 Weka
中相当冗长的交叉验证方法提供的所有信息。因此,R 脚本应该从 Weka 输出类似 [a] 的内容。
RWeka
验证 R 模型以生成这些度量?rfcv
?我无法让它工作。我知道随机森林中使用的包外错误 (OOB) 是某种交叉验证。但我需要完整的信息才能进行合适的比较。
到目前为止,我使用 R 尝试的是 [b]。但是,由于缺少值,代码还会在我的设置 [c] 上产生错误。
那么,你能帮我做交叉验证吗?
[a] 维卡:
=== Stratified cross-validation ===
=== Summary ===
Correctly Classified Instances 3059 96.712 %
Incorrectly Classified Instances 104 3.288 %
Kappa statistic 0.8199
Mean absolute error 0.1017
Root mean squared error 0.1771
Relative absolute error 60.4205 %
Root relative squared error 61.103 %
Coverage of cases (0.95 level) 99.6206 %
Mean rel. region size (0.95 level) 78.043 %
Total Number of Instances 3163
=== Detailed Accuracy By Class ===
TP Rate FP Rate Precision Recall F-Measure MCC ROC Area PRC Area Class
0,918 0,028 0,771 0,918 0,838 0,824 0,985 0,901 sick-euthyroid
0,972 0,082 0,991 0,972 0,982 0,824 0,985 0,998 negative
Weighted Avg. 0,967 0,077 0,971 0,967 0,968 0,824 0,985 0,989
=== Confusion Matrix ===
a b <-- classified as
269 24 | a = sick-euthyroid
80 2790 | b = negative
[b] 目前的代码:
library(randomForest) #randomForest() and rfImpute()
library(foreign) # read.arff()
library(caret) # train() and trainControl()
nTrees <- 2 # 200
myDataset <- 'D:\\your\\directory\\SE.arff' # http://hakank.org/weka/SE.arff
mydb = read.arff(myDataset)
mydb.imputed <- rfImpute(class ~ ., data=mydb, ntree = nTrees, importance = TRUE)
myres.rf <- randomForest(class ~ ., data=mydb.imputed, ntree = nTrees, importance = TRUE)
summary(myres.rf)
# specify type of resampling to 10-fold CV
fitControl <- trainControl(method = "rf",number = 10,repeats = 10)
set.seed(825)
# deal with NA | NULL values in categorical variables
#mydb.imputed[is.na(mydb.imputed)] <- 1
#mydb.imputed[is.null(mydb.imputed)] <- 1
rfFit <- train(class~ ., data=mydb.imputed,
method = "rf",
trControl = fitControl,
## This last option is actually one
## for rf() that passes through
ntree = nTrees, importance = TRUE, na.action = na.omit)
rfFit
错误是:
Error in names(resamples) <- gsub("^\\.", "", names(resamples)) :
attempt to set an attribute on NULL
使用traceback()
5: nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo,
method = models, ppOpts = preProcess, ctrl = trControl, lev = classLevels,
...)
4: train.default(x, y, weights = w, ...)
3: train(x, y, weights = w, ...)
2: train.formula(class~ ., data = mydb.imputed, method = "rf",
trControl = fitControl, ntree = nTrees, importance = TRUE,
sampsize = rep(minorityClassNum, 2), na.action = na.omit)
1: train(class~ ., data = mydb.imputed, method = "rf", trControl = fitControl,
ntree = nTrees, importance = TRUE, sampsize = rep(minorityClassNum,
2), na.action = na.omit) at #39
[c] R 版本信息通过 sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: i386-w64-mingw32/i386 (32-bit)
[...]
other attached packages:
[1] e1071_1.6-3 caret_6.0-30 ggplot2_1.0.0 foreign_0.8-61 randomForest_4.6-7 DMwR_0.4.1
[7] lattice_0.20-29 JGR_1.7-16 iplots_1.1-7 JavaGD_0.6-1 rJava_0.9-6
最佳答案
我不知道 weka,但我在 R 中进行了随机森林建模,并且我一直使用 R 中的预测函数来执行此操作。
尝试使用这个函数
predict(Model,data)
将输出与原始值绑定(bind),使用table命令得到混淆矩阵。
关于r - 使用 R 在 randomForest 上执行交叉验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24364430/
我想使用单个(交叉)编译器来编译不同 ARM 调用约定的代码:因为我总是想使用浮点和 NEON 指令,所以我只想选择硬浮点调用约定或软浮点(softfp)调用约定。 我的编译器默认为硬浮点,但它支持我
假设我正在构建一个依赖于两个库的 java 应用程序:A 和 B。A 和 B 都依赖于库 C。管理 A 和 B 使用相同版本的最佳方法是什么所以他们不冲突?我正在使用 Gradle。 最佳答案 从 G
我想在按钮的文本上添加图像。如果我将图像添加为按钮的背景,它就会添加到文本下方。预期结果作为图像添加。请帮忙 更新:我需要以编程方式执行此操作。 最佳答案 在 XML 中, * 在代码中
我已经开始使用 CSS3 制作动画了。 我尝试创建一个动画汉堡菜单,但结果有点难看。顶部和底部的条向右平移一点。所以旋转动画不是很流畅和正确。 这是结果 => 这是我的代码: /* HTML */
给定一个具有2条相交曲线的图像,如下图所示,我如何使用opencv或python检测和区分2条曲线? (所以我需要2条单独的曲线) 最佳答案 您可以扫描每一列,并从连接的零件中识别出簇。 伪算法: l
我正在尝试在 redhat 集群(x86_64 主机)上设置 cross-mingw。我没有 root 访问权限,并且可用的 mingw 二进制文件不起作用(坏 glibc 版本等)。我正在阅读本教程
我正在尝试在javaFX中开发一个游戏,当两个图像相交时,分数将被更新,并且障碍物将不可见。但不幸的是,在游戏中分数不断更新。 我想我无法在游戏中正确地使图像不可见。 以下是相关类的完整代码: pac
pikastar dot com 是网站,当向下滚动它然后在导航菜单展开固定位置时它 > 将穿过主 div。我该如何修复它。 #topNav.sticky { box-shadow: 0 10
我正在使用 Eclipse为 ARM 处理器交叉编译 g++ 项目。我在 Windows 环境中使用 yagarto 工具链。我对 C 项目没有问题,但是对于 C++,我一直收到错误: libc.a(
我想从两个哈希数组中获取并集/交集/差集,例如: array1 = [{:name =>'Guy1', :age => 45},{:name =>'Guy2', :age => 45}] array2
有没有办法在调用任何 Controller 操作之前执行一些代码? 我需要根据 get 参数的值设置 session 变量,而不考虑调用哪个 Controller 。 当然,一旦这个处理完成,请求需要
我刚开始使用 3D 网格,面向用于有限元分析。我想在立方体状矩阵中模拟 Material 的夹杂物(任何形状,但主要对球体和椭圆体感兴趣)。这些夹杂物不应彼此重合。 所以我想为python使用某种包,
我想知道以跨平台方式操作应用程序设置的最佳解决方案是什么。 在 iOS 中,我们可以在设置屏幕中更改应用程序外部的设置,但在 windows phone 和 android 中我们没有。 所以,我的想
var barcodeNum = ko.observable(""); VelocityMeetings.scan = function (params) { var errorMessage = k
这个问题在这里已经有了答案: Transforming data.frame in R (2 个答案) 关闭10 年前。 过去我问过一个关于如何create cross tables from a
我有两个共享同一个工厂的 Controller 。其中一个 Controller 正在更新工厂变量。其他人应该注意该变化并稍后显示。 我是这样尝试的: http://plnkr.co/edit/q1N
标题不好,但这是我发现的将我的问题与简单的表格交叉区分开来的方式,因为我之前的研究总是让我接触到这类主题。 我有几个表 - 为了简化起见,我们只用 3 个表来命名它们:A、B、C。我想将它们全部放在一
我需要做这样的事情(在 MySQL 中),我使用 UNION 的尝试直到现在才奏效。 理论上: SELECT * FROM tableA A JOIN tableB B ON A.tableAId =
注意:使用SDL 2.0,Cross header class问题 我在类之间进行交叉引用,主要是我的类初始化渲染器和我的纹理类引用渲染初始化。现在,我已经能够运行该程序,直到我开始放入纹理类,代码也
我有一个这样的字母数组 var letters = ["Y", "X", "A", "Y", "O", "H", "A", "O", "O"]; 我创建了一个循环来
我是一名优秀的程序员,十分优秀!