- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我无法从文档中判断 predict.H2OModel()
来自 h2o
的函数R 中的包为使用 h2o.randomForest()
构建的随机森林模型提供 OOB 预测.
其实在我试过的3-4个例子中,似乎是predict.H2OModel()
的结果更接近于来自 predict.randomForest()
的非 OOB 预测来自 randomForest
包比OOB的。
有谁知道它们是否是OOB预测?如果没有,您知道如何获得 h2o.randomForest()
的 OOB 预测吗?楷模?
例子:
set.seed(123)
library(randomForest)
library(h2o)
data(mtcars)
d = mtcars[,c('mpg', 'cyl', 'disp', 'hp', 'wt' )]
## define some common settings for both random forests
n.trees=1000
mtry = 3
min.node = 3
## prep for h2o.randomForest
h2o.init()
d.h2o= as.h2o(d)
x.names = colnames(d)[2:5] ## predictors
## fit both models
set.seed(123);
rf = randomForest(mpg ~ ., data = d , ntree=n.trees, mtry = mtry, nodesize=min.node)
h2o = h2o.randomForest(y='mpg', x=x.names, training_frame = d.h2o, ntrees=n.trees, mtries = mtry, min_rows=min.node)
## Correct way and incorrect way of getting OOB predictions for a randomForest model. Not sure about h2o model.
d$rf.oob.pred = predict(rf) ## Gives OOB predictions
d$rf.pred = predict(rf , newdata=d ) ## Doesn't give OOB predictions.
d$h2o.pred = as.vector(predict(h2o, newdata=d.h2o)) ## Not sure if this is OOB or not.
## d$h2o.pred seems more similar to d$rf.pred than d$rf.oob.pred,
## suggesting that predict.H2OModel() might not give OOB predictions.
mean((d$rf.pred - d$h2o.pred)^2)
mean((d$rf.oob.pred - d$h2o.pred)^2)
最佳答案
H2O's h2o.predict()不提供 OOB 数据的预测。您必须使用 newdata =
指定要预测的数据集范围。所以当你有 newdata=d.h2o
那么您将得到 d.h2o
的预测您指定的数据框。
目前没有方法来获得 oob 数据的预测。但是,有一个 jira ticket指定您是否需要 oob 指标(请注意,此票还链接到另一个票,这有助于阐明当前如何为随机森林报告训练指标)。
关于r - R 中 h2o 包中的 predict.H2OModel() 是否为 h2o.randomForest() 模型提供 OOB 预测?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50458586/
setwd("D:/Santander") ## import train dataset train0.9999] train2<-train[,! colnames(train) %in% c(e
当我运行这样的代码时,我对获得的不同结果感到困惑: set.seed(100) test1<-randomForest(BinaryY~., data=Xvars, trees=51, mtry=5,
当我通过拆分单个数据帧创建训练集和测试集并使用 randomForest 包构建随机森林时,对于训练数据中不存在的某些因子级别, predict() 函数仍然会抛出一个输出。虽然这没有给出错误(这是我
当尝试在因子水平低于我的训练数据的新测试数据上测试我的训练模型时,predict()返回以下内容: Type of predictors in new data do not match that o
我正在尝试使用 randomForest 进行分类,但我反复收到一条错误消息,似乎没有明显的解决方案(randomForest 在过去对我进行回归时效果很好)。我在下面粘贴了我的代码。 “成功”是一个
我想训练我的模型并选择最佳的树数量。代码在这里 from sklearn.ensemble import RandomForestClassifier tree_dep = [3,5,6] tree_
有谁知道 R randomForest 包用来解决分类关系的机制是什么 - 即当树最终在两个或多个类别中获得相同的投票时? 文档说领带是随机断开的。但是,当您在一组数据上训练模型,然后使用一组验证数据
我在使用 RandomForest 拟合函数时遇到问题 这是我的训练集 P1 Tp1 IrrPOA Gz Drz2 0
在 randomForest 包中实现的 R 随机森林算法对数字类和整数类的变量的行为是否相同? 最佳答案 是的,randomForest 实现确实对待整数和数字( double )类似。在 RF 模
重要性图: 我想将 y 轴文本向右对齐,并且还想根据不同的变量组为变量着色。例如 Limonene 和 Valencane,a-Selinene 和 g-Selinen 分别属于同一组。 但我在 "r
R 3.0.0 的新特性之一是引入了长向量。但是, .C() 和 .Fortran() 不接受长向量输入。在 R-bloggers我发现: This is a precaution as it is
我一直在用 R 对 700 万行数据(41 个特征)训练 randomForest 模型。这是一个示例调用: myModel <- randomForest(RESPONSE~., data=myda
我一直在尝试安装 R 包“randomForest”,为此我运行了通常的安装命令 install.packages("randomForest", dependencies = T) 这给了我以下错误
我正在尝试构建一个在线随机森林分类器。在 for 循环中,我遇到了一个错误,但找不到原因。 clf = RandomForestClassifier(n_estimators=1, warm_star
如果我运行 randomForest(y ~ x, data = df) 模型,x 会得到超过 53 个级别的因子变量 Error in randomForest.default(m, y, ...)
我在 R 中使用 randomForest 包来构建几个物种分布模型。我的响应变量是二元的(0 - 缺席或 1 存在),并且非常不平衡 - 对于某些物种,缺席:存在的比率是 37:1。这种不平衡(或零
我刚刚开始使用 Weka,当我的决策树太深时我无法理解。我有一组 423 个特征,据我所知,这些特征是为每个目标随机选择的。因此,这些特征子集生成带有决策叶的分支或流程,这些决策叶似乎不通用,实际上它
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 5 年前。 Improve this ques
我的数据高度不平衡,想要对少数类进行上采样以提高准确性(少数类是感兴趣的对象)。 我尝试在“randomForest”函数中使用“sampsize”选项 - 但它只允许下采样。我在某个地方读到,可以使
我有一个包含 10,000 行和两列的数据框、段(具有 32 个值的因子)和目标(具有两个值"is"和“否”的因子,每个值 5,000 个)。我正在尝试使用随机森林来使用分段作为特征对目标进行分类。
我是一名优秀的程序员,十分优秀!