- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我希望使用 GBM
包进行逻辑回归,但它给出的答案略超出 0-1 范围。我已经尝试了 0-1 预测的建议分布参数( bernoulli
和 adaboost
),但这实际上比使用 gaussian
更糟。 .
GBM_NTREES = 150
GBM_SHRINKAGE = 0.1
GBM_DEPTH = 4
GBM_MINOBS = 50
> GBM_model <- gbm.fit(
+ x = trainDescr
+ ,y = trainClass
+ ,distribution = "gaussian"
+ ,n.trees = GBM_NTREES
+ ,shrinkage = GBM_SHRINKAGE
+ ,interaction.depth = GBM_DEPTH
+ ,n.minobsinnode = GBM_MINOBS
+ ,verbose = TRUE)
Iter TrainDeviance ValidDeviance StepSize Improve
1 0.0603 nan 0.1000 0.0019
2 0.0588 nan 0.1000 0.0016
3 0.0575 nan 0.1000 0.0013
4 0.0563 nan 0.1000 0.0011
5 0.0553 nan 0.1000 0.0010
6 0.0546 nan 0.1000 0.0008
7 0.0539 nan 0.1000 0.0007
8 0.0533 nan 0.1000 0.0006
9 0.0528 nan 0.1000 0.0005
10 0.0524 nan 0.1000 0.0004
100 0.0484 nan 0.1000 0.0000
150 0.0481 nan 0.1000 -0.0000
> prediction <- predict.gbm(object = GBM_model
+ ,newdata = testDescr
+ ,GBM_NTREES)
> hist(prediction)
> range(prediction)
[1] -0.02945224 1.00706700
GBM_model <- gbm.fit(
x = trainDescr
,y = trainClass
,distribution = "bernoulli"
,n.trees = GBM_NTREES
,shrinkage = GBM_SHRINKAGE
,interaction.depth = GBM_DEPTH
,n.minobsinnode = GBM_MINOBS
,verbose = TRUE)
prediction <- predict.gbm(object = GBM_model
+ ,newdata = testDescr
+ ,GBM_NTREES)
> hist(prediction)
> range(prediction)
[1] -4.699324 3.043440
GBM_model <- gbm.fit(
x = trainDescr
,y = trainClass
,distribution = "adaboost"
,n.trees = GBM_NTREES
,shrinkage = GBM_SHRINKAGE
,interaction.depth = GBM_DEPTH
,n.minobsinnode = GBM_MINOBS
,verbose = TRUE)
> prediction <- predict.gbm(object = GBM_model
+ ,newdata = testDescr
+ ,GBM_NTREES)
> hist(prediction)
> range(prediction)
[1] -3.0374228 0.9323279
prediction <- ifelse(prediction < 0, 0, prediction)
prediction <- ifelse(prediction > 1, 1, prediction)
最佳答案
来自 ?predict.gbm
:
Returns a vector of predictions. By default the predictions are on the scale of f(x). For example, for the Bernoulli loss the returned value is on the log odds scale, poisson loss on the log scale, and coxph is on the log hazard scale.
If type="response" then gbm converts back to the same scale as the outcome. Currently the only effect this will have is returning probabilities for bernoulli and expected counts for poisson. For the other distributions "response" and "link" return the same.
distribution="bernoulli"
,您需要转换预测值以将它们重新缩放为 [0, 1]:
p <- plogis(predict.gbm(model))
.使用
distribution="gaussian"
实际上是用于回归而不是分类,尽管我很惊讶预测不在 [0, 1] 中:我的理解是 gbm 仍然基于树,因此预测值不应该超出训练数据中存在的值。
关于R gbm 逻辑回归,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8410846/
背景 gbm 包 的引用手册指出,interact.gbm 函数计算 Friedman 的 H 统计量以评估变量相互作用的强度。 H 统计量的范围为 [0-1]。 dismo 包的引用手册没有引用任何
修改梯度提升,我注意到 R 的 gbm 包在一个最小的示例中产生与 h2o 不同的结果。为什么? 数据 library(gbm) library(h2o) h2o.init() train <- da
有没有办法将 gbm 模型导出到 C++。具体来说,我如何调用 predict.gbm 函数在 R 之外运行以便对新数据集进行评分。 我已将模型导出为 PMML 文件,但我不确定新数据集将如何基于 P
我正在尝试运行 GradientBoostingClassifier()在 gridsearchcv 的帮助下。 对于每个参数组合,我还需要表格格式的“精确度”、“召回率”和准确性。 这是代码: sc
我希望使用 GBM包进行逻辑回归,但它给出的答案略超出 0-1 范围。我已经尝试了 0-1 预测的建议分布参数( bernoulli 和 adaboost ),但这实际上比使用 gaussian 更糟
我遇到了一个奇怪的问题。我已在笔记本电脑上成功运行此代码,但是当我尝试首先在另一台计算机上运行它时,我收到此警告未指定分布,假设伯努利...,这是我所期望的,但随后出现此错误:object$var.l
我正在尝试使用 R 中的 gbm.more 函数。为了清楚起见,我使用了规范的虹膜数据。当我指定 distribution="multinomial"时,下面的代码不起作用,但是当我指定 distri
我使用了gbm函数来实现梯度提升。我想进行分类。之后,我使用 varImp() 函数在梯度提升建模中打印变量重要性。但是......只有 4 个变量具有非零重要性。我的大数据里有371个变量....对
类似的问题是 asked但是答案中的链接指向随机森林示例,在我的情况下似乎不起作用。 这是我正在尝试做的一个例子: gbmGrid <- expand.grid(interaction.depth
为分类问题运行 gbm 函数时。我收到以下错误: Error in res[flag, ] 0.5,1,0) table(pred,df$Group) pred 0 1 0 98
我使用 R 包 GBM 作为预测建模的首选。这个算法有很多很棒的东西,但一个“坏”是我不能轻易地使用模型代码来对 R 之外的新数据进行评分。我想编写可以在 SAS 或其他系统中使用的代码(我将从SAS
我正在解决一个多类分类问题并尝试使用广义提升模型(R 中的 gbm 包)。我面临的问题:插入符号 train功能与 method="gbm"似乎不能正确处理多类数据。下面给出一个简单的例子。 libr
我正在尝试使用 Friedman 和 Popescu 2008 https://projecteuclid.org/euclid.aoas/1223908046 中描述的方法确定 gbm 模型中的哪些
我有一个相当小的数据集(162,000 个观察值,13 个属性)我正在尝试使用 h2o.GBM 进行建模。响应变量是具有大量级别的分类变量(~ 20,000 个级别)该模型没有耗尽内存或给出任何错误,
是否可以绘制部分依赖图来显示类概率并估计预测变量对 GBM 的影响?模型?类似于 randomForest 包中的 partialPlot。 根据 this article ,部分情节可以用 gbm
我使用提前停止和设置 ntrees=10000 在水中训练了 GBM。我想检索模型中实际存在的树木数量。但是,如果我调用 model.params['ntrees'] (其中 model 是网格搜索中
我正在尝试使用 caret在 R 中打包用于具有用户定义的性能指标的多个嵌套交叉验证过程。我遇到了各种各样的问题,所以我回过头来看看是否有更多开箱即用的 caret 的问题。看来我遇到了一个。 如果我
在传统的GBM中,我们可以使用 Predict.gbm(模型, newsdata=..., n.tree=...) 这样我就可以将测试数据的结果与不同数量的树进行比较。 在h2o.gbm中,虽然有n.
我对 light gbm 使用了自定义指标,但提前停止了对数损失的工作,这是目标函数,我如何解决这个问题或更改提前停止以适用于评估指标。 def evaluate_macroF1_lgb(truth,
R gbm 中的 weights 参数是什么?功能?它是否实现了成本敏感随机梯度提升? 最佳答案 您可能已经阅读过本文,但文档说 weights 参数是这样定义的: an optional vecto
我是一名优秀的程序员,十分优秀!