Answers:
您应该发现这些与确定基础函数数(即迭代)(即加法模型中的树数)的最佳值有关。我找不到确切描述这些内容的文档,但这是我的最佳猜测,也许其他人可以发表评论。
从手册中获取以下内容:
library(gbm)
# A least squares regression example
# create some data
N <- 1000
X1 <- runif(N)
X2 <- 2*runif(N)
X3 <- ordered(sample(letters[1:4],N,replace=TRUE),levels=letters[4:1])
X4 <- factor(sample(letters[1:6],N,replace=TRUE))
X5 <- factor(sample(letters[1:3],N,replace=TRUE))
X6 <- 3*runif(N)
mu <- c(-1,0,1,2)[as.numeric(X3)]
SNR <- 10 # signal-to-noise ratio
Y <- X1**1.5 + 2 * (X2**.5) + mu
sigma <- sqrt(var(Y)/SNR)
Y <- Y + rnorm(N,0,sigma)
# introduce some missing values
X1[sample(1:N,size=500)] <- NA
X4[sample(1:N,size=300)] <- NA
data <- data.frame(Y=Y,X1=X1,X2=X2,X3=X3,X4=X4,X5=X5,X6=X6)
# fit initial model
gbm1 <- gbm(Y~X1+X2+X3+X4+X5+X6, # formula
data=data, # dataset
var.monotone=c(0,0,0,0,0,0), # -1: monotone decrease,
# +1: monotone increase,
# 0: no monotone restrictions
distribution="gaussian", # bernoulli, adaboost, gaussian,
# poisson, coxph, and quantile available
n.trees=3000, # number of trees
shrinkage=0.005, # shrinkage or learning rate,
# 0.001 to 0.1 usually work
interaction.depth=3, # 1: additive model, 2: two-way interactions, etc.
bag.fraction = 0.5, # subsampling fraction, 0.5 is probably best
train.fraction = 0.5, # fraction of data for training,
# first train.fraction*N used for training
n.minobsinnode = 10, # minimum total weight needed in each node
cv.folds = 5, # do 5-fold cross-validation
keep.data=TRUE, # keep a copy of the dataset with the object
verbose=TRUE) # print out progress
迭代数(Iter
)为3000,这是选择要构建的树的数量(1到3000,虽然未显示每棵)。顺便说一句,整个过程重复了5次,因为我们选择了cv.folds = 5。
StepSize
是所选的收缩率或学习率(此处为0.005)。
我相信这Improve
是通过添加另一棵树来减少偏差(损失函数)的方法,并且使用袋外(OOB)记录进行计算(请注意,如果bag.fraction不小于1,则不会计算出来)。
然后,对于每次迭代,TrainDeviance ValidDeviance
是训练数据和保留数据(单个保留集)上损失函数的值。如果train.fraction
不小于1,则不会计算ValidDeviance 。
你见过这样描述了3种方法确定树木的最优数量?