使用插入符号在R中进行交叉验证的SVM

use*_*207 15 r svm r-caret

有人告诉我使用插入包来执行支持向量机回归,对我拥有的数据集进行10倍交叉验证.我正在针对151个变量绘制我的响应变量.我做了以下事情: -

> ctrl <- trainControl(method = "repeatedcv", repeats = 10)
> set.seed(1500)
> mod <- train(RT..seconds.~., data=cadets, method = "svmLinear", trControl = ctrl)
Run Code Online (Sandbox Code Playgroud)

我得到了

C    RMSE  Rsquared  RMSE SD  Rsquared SD
  0.2  50    0.8       20       0.1        
  0.5  60    0.7       20       0.2        
  1    60    0.7       20       0.2   
Run Code Online (Sandbox Code Playgroud)

但我希望能够看一下我的折叠,并且对于每个折叠,预测值与实际值的接近程度.我怎么去看这个?

此外,它说: -

RMSE was used to select the optimal model using  the smallest value.
The final value used for the model was C = 0.
Run Code Online (Sandbox Code Playgroud)

我只是想知道这意味着什么以及C在上表中代表什么?

RT (seconds)    76_TI2  114_DECC    120_Lop 212_PCD 236_X3Av
38  4.086   1.2 2.322   0   0.195
40  2.732   0.815   1.837   1.113   0.13
41  4.049   1.153   2.117   2.354   0.094
41  4.049   1.153   2.117   3.838   0.117
42  4.56    1.224   2.128   2.38    0.246
42  2.96    0.909   1.686   0.972   0.138
42  3.237   0.96    1.922   1.202   0.143
44  2.989   0.8 1.761   2.034   0.11
44  1.993   0.5 1.5 0   0.102
44  2.957   0.8 1.761   0.988   0.141
44  2.597   0.889   1.888   1.916   0.114
44  2.428   0.691   1.436   1.848   0.089
Run Code Online (Sandbox Code Playgroud)

这是我的数据集的snipet.我正在尝试对151个变量进行RT秒.

谢谢

Dav*_*vid 19

您必须通过对象中的"savePred"选项保存CV预测trainControl.我不确定你的"学员"数据来自哪个包,但这里有一个使用虹膜的简单示例:

> library(caret)
> ctrl <- trainControl(method = "cv", savePred=T, classProb=T)
> mod <- train(Species~., data=iris, method = "svmLinear", trControl = ctrl)
> head(mod$pred)
        pred        obs      setosa  versicolor   virginica rowIndex   .C Resample
1     setosa     setosa 0.982533940 0.009013592 0.008452468       11 0.25   Fold01
2     setosa     setosa 0.955755054 0.032289120 0.011955826       35 0.25   Fold01
3     setosa     setosa 0.941292675 0.044903583 0.013803742       46 0.25   Fold01
4     setosa     setosa 0.983559919 0.008310323 0.008129757       49 0.25   Fold01
5     setosa     setosa 0.972285699 0.018109218 0.009605083       50 0.25   Fold01
6 versicolor versicolor 0.007223973 0.971168170 0.021607858       59 0.25   Fold01
Run Code Online (Sandbox Code Playgroud)

编辑:"C"是SVM的调整参数之一.ksvm有关更多详细信息,请查看kernlab包中函数的帮助.

EDIT2:琐碎的回归示例

> library(caret)
> ctrl <- trainControl(method = "cv", savePred=T)
> mod <- train(Sepal.Length~., data=iris, method = "svmLinear", trControl = ctrl)
> head(mod$pred)
      pred obs rowIndex   .C Resample
1 4.756119 4.8       13 0.25   Fold01
2 4.910948 4.8       31 0.25   Fold01
3 5.094275 4.9       38 0.25   Fold01
4 4.728503 4.8       46 0.25   Fold01
5 5.192965 5.3       49 0.25   Fold01
6 5.969479 5.9       62 0.25   Fold01
Run Code Online (Sandbox Code Playgroud)