利用caret软件包寻找GBM的最佳参数
我正在使用R GBM软件包对一些10000 X 932维度的生物数据进行boosting回归,我想知道GBM软件包的最佳参数设置是什么(n.trees、restriction、interaction.depth和n.minobsinnode)。当我在线搜索时,我发现R上的CARET软件包可以找到这些参数设置。但是,我很难将插入符号包与GBM包一起使用,所以我只想知道如何使用插入符号来找到前面提到的参数的最佳组合?我知道这似乎是一个非常典型的问题,但我阅读了插入符号手册,在将插入符号与gbm集成方面仍然有困难,特别是因为我对这两个软件包都是非常陌生的此链接有一个具体的示例(第10页)——利用caret软件包寻找GBM的最佳参数,r,optimization,r-caret,gbm,R,Optimization,R Caret,Gbm,我正在使用R GBM软件包对一些10000 X 932维度的生物数据进行boosting回归,我想知道GBM软件包的最佳参数设置是什么(n.trees、restriction、interaction.depth和n.minobsinnode)。当我在线搜索时,我发现R上的CARET软件包可以找到这些参数设置。但是,我很难将插入符号包与GBM包一起使用,所以我只想知道如何使用插入符号来找到前面提到的参数的最佳组合?我知道这似乎是一个非常典型的问题,但我阅读了插入符号手册,在将插入符号与gbm集成方
基本上,应该首先为超参数(如n.trees、interaction.depth和contraction)创建候选值网格。然后像往常一样调用通用的train函数。不确定是否找到了要查找的内容,但我发现其中一些表单没有什么帮助 如果您使用的是插入符号包,下面将描述所需的参数:>getModelInfo()$gbm$parameters 他为运行GBM提供了一些经验法则:
getModelInfo()$gbm$parameters
library(parallel)
library(doMC)
registerDoMC(cores = 20)
# Max shrinkage for gbm
nl = nrow(training)
max(0.01, 0.1*min(1, nl/10000))
# Max Value for interaction.depth
floor(sqrt(NCOL(training)))
gbmGrid <- expand.grid(interaction.depth = c(1, 3, 6, 9, 10),
n.trees = (0:50)*50,
shrinkage = seq(.0005, .05,.0005),
n.minobsinnode = 10) # you can also put something like c(5, 10, 15, 20)
fitControl <- trainControl(method = "repeatedcv",
repeats = 5,
preProcOptions = list(thresh = 0.95),
## Estimate class probabilities
classProbs = TRUE,
## Evaluate performance using
## the following function
summaryFunction = twoClassSummary)
# Method + Date + distribution
set.seed(1)
system.time(GBM0604ada <- train(Outcome ~ ., data = training,
distribution = "adaboost",
method = "gbm", bag.fraction = 0.5,
nTrain = round(nrow(training) *.75),
trControl = fitControl,
verbose = TRUE,
tuneGrid = gbmGrid,
## Specify which metric to optimize
metric = "ROC"))
getModelInfo()$gbm$参数
图书馆(平行)
图书馆(doMC)
寄存器DOMC(核心=20)
#gbm的最大收缩率
nl=nrow(培训)
最大值(0.01,0.1*最小值(1,nl/10000))
#交互的最大值。深度
楼层(sqrt(NCOL(培训)))
gbmGrid