有没有人熟悉如何弄清楚gbm
R 中的模型内部发生了什么?
假设我们想看看如何预测Petal.Length
in iris。为了简单起见,我跑了:
tg=gbm(Petal.Length~.,data=iris)
这有效,当您运行时:
summary(tg)
然后你得到:
Hit <Return> to see next plot:
var rel.inf
Petal.Width Petal.Width 67.39
Species Species 32.61
Sepal.Length Sepal.Length 0.00
Sepal.Width Sepal.Width 0.00
这在直觉上是有道理的。当你运行pretty.gbm.tree(tg)
你得到:
SplitVar SplitCodePred LeftNode RightNode MissingNode ErrorReduction Weight Prediction
0 2 0.8000000000 1 2 3 184.6764 75 0.0001366667
1 -1 -0.0022989091 -1 -1 -1 0.0000 22 -0.0022989091
2 -1 0.0011476604 -1 -1 -1 0.0000 53 0.0011476604
3 -1 0.0001366667 -1 -1 -1 0.0000 75 0.0001366667
很明显,gbm 认为您按变量 #2 拆分并返回三个单独的回归。我认为这SplitVar==2
是Petal.Width
因为您看到的顺序str(iris)
是有道理的。
但是缺少哪些数据? iris
没有缺失数据。然后我们如何查看创建的三个节点中的每一个节点中发生了什么?
假设我想用 C++ 编写代码用于生产,除了知道你应该根据 if 做不同的事情之外,我不知道如何知道要编写什么代码Petal.Width >.8
。
谢谢,
乔什