简体   繁体   English

R:插入符号如何选择默认调音范围?

[英]R: how does caret choose default tuning range?

When using R caret to compare multiple models on the same data set, caret is smart enough to select different tuning ranges for different models if the same tuneLength is specified for all models and no model-specific tuneGrid is specified. 当使用R caret到多个车型上相同的数据集进行比较, caret是足够聪明的选择,如果同一型号不同不同的调谐范围tuneLength所有型号是指定的,没有具体的模型tuneGrid指定。

For example, the tuning ranges chosen by caret for one particular data set are: 例如, caret为一个特定数据集选择的调整范围是:

earth(nprune) : 2, 5, 8, 11, 14 earth(nprune)earth(nprune)

gamSpline(df) : 1, 1.5, 2, 2.5, 3 gamSpline(df)gamSpline(df)

rpart(cp) : 0.010, 0.054, 0.116, 0.123, 0.358 rpart(cp) :0.010,0.054,0.116,0.123,0.358

Does anyone know how caret determines these default tuning ranges? 有人知道caret如何确定这些默认调整范围吗? I have been searching through the documentation but still haven't pinned down the algorithm to choose the ranges. 我一直在搜索文档,但仍没有确定选择范围的算法。

It depends on the model. 这取决于型号。 For rpart and a few others, it fits and initial model to get a sense of what reasonable values should be. 对于rpart和其他一些而言,它适合初始模型,以了解应该是什么合理值。 In other cases, it is less intelligent. 在其他情况下,它的智能程度较低。 For example, for gamSpline it is expand.grid(df = seq(1, 3, length = len)) . 例如,对于gamSpline它是expand.grid(df = seq(1, 3, length = len))

You can see what it does per model using getModelInfo : 您可以使用getModelInfo查看每个模型的作用:

 > getModelInfo("earth")[[1]]$grid
 function(x, y, len = NULL) {
       dat <- if(is.data.frame(x)) x else as.data.frame(x)
       dat$.outcome <- y

       mod <- earth( .outcome~., data = dat, pmethod = "none")
       maxTerms <- nrow(mod$dirs)
       maxTerms <- min(200, floor(maxTerms * .75) + 2)
       data.frame(nprune = unique(floor(seq(2, to = maxTerms, length = len))),
                  degree = 1)
  }

Max 马克斯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM