nnet 在插入符号中。自举还是交叉验证?

数据挖掘 机器学习 神经网络 r 交叉验证 自举
2022-03-11 03:59:26

我想用插入符号中的 nnet 训练具有一个隐藏层的浅层神经网络。在 trainControl 中,我使用 method = "cv" 执行 3 折交叉验证。剪切的代码和结果摘要如下。

  myControl <- trainControl(## 3-fold CV
    method = "cv",
    number = 3)
  
  nnGrid <-  expand.grid(size = seq(1, 10, 3),
                         decay = c(0, 0.2, 0.4))
  
  set.seed(1234)
  
  nnetFit <- train(choice ~ .,
                   data = db,
                   method = "nnet",
                   maxit = 1000,
                   tuneGrid = nnGrid,
                   trainControl = myControl)

我有几个疑问 -

  1. 结果(附在下面)表明它执行的是引导(25 次重复)而不是交叉验证(我接受的模型只针对每组超参数的 3-cv 训练了 3 次)。

  2. 我只想 100% 确定模型是否使用原始数据进行训练,而无需任何预处理,例如居中和缩放。

  3. 我在 trainControl 中使用了 verboseIter = FALSE,但它仍然打印所有迭代

  4. 其他库(例如神经网络、mxnet)是否比 nnet 更好,我可以在这里替换它们。

  5. 我想确定 nnet 是否在隐藏层中使用 sigmoid 激活函数。

有人可以建议吗?

No pre-processing
Resampling: Bootstrapped (25 reps) 
Summary of sample sizes: 3492, 3492, 3492, 3492, 3492, 3492, ... 
Resampling results across tuning parameters:

  size  decay  Accuracy   Kappa       
   1    0.0    0.4947424  -0.002382083
   1    0.2    0.5686601   0.141749447
   1    0.4    0.5711497   0.143637446
   4    0.0    0.5076199   0.022765002
   4    0.2    0.7333516   0.468625768
   4    0.4    0.7253675   0.452584882
   7    0.0    0.5002912   0.006079340
   7    0.2    0.7440360   0.488933678
   7    0.4    0.7676500   0.536547080
  10    0.0    0.5064281   0.013648966
  10    0.2    0.7668795   0.535370693
  10    0.4    0.7566465   0.513652332

Accuracy was used to select the optimal model using the largest value.
The final values used for the model were size = 7 and decay = 0.4.
1个回答
  1. 您的火车功能有误。它不应该是trControl trainControl。

  2. 默认情况下,该train函数不进行任何预处理 ( preProcess = NULL)

  3. 具有停止向屏幕打印轨迹trace = FALSE的功能。train

  4. caret您可以在https://topepo.github.io/caret/available-models.html找到可用的模型

  5. 看起来 nnet 对隐藏层使用了 sigmoidal 激活函数;见这里https://stats.stackexchange.com/questions/78252/whats-the-activation-function-used-in-the-nodes-of-hidden-layer-from-nnet-libra

此外,您可能希望为回归和分类设置linout参数。TRUEFALSE