regLogistic:从插入符号中收集参数

时间:2018-06-13 17:03:40

标签: r r-caret

请考虑以下事项:

library(dplyr)
library(caret)

set.seed(42)

levels(iris$Species) <- list("setosa" = c("setosa"), "not_setosa" = c("versicolor", "virginica"))
train <- sample.int(0.5*nrow(iris))
test <- setdiff((1:nrow(iris)), train)
m <- train(factor(Species) ~ .,
           data = iris %>% slice(train),
           method = "regLogistic",
           trControl = trainControl(method = "repeatedcv",
                                    number = 10,
                                    repeats = 3),
           tuneGrid = expand.grid(.cost = 1,
                                  .loss = c("L1", "L2_dual", "L2_primal"),
                                  .epsilon = seq(0.001, 0.01, length.out = 5)),
           metric = "Accuracy",
           preProcess = c("center", "scale"))

> m$bestTune
  cost loss epsilon
1    1   L1   0.001

如何收集此处使用的L_1惩罚逻辑回归模型中使用的参数值(即系数值)?

0 个答案:

没有答案