Pergunta

This may be a silly question, but I performed SVM on my data, and the best fit of the model comes out to be when C = 0.5 as it gives the best RMSE value. Which is great. I performed 10-cross fold validation on it, ten times by doing the following:-

ctrl <- trainControl(method = "repeatedcv", repeats = 10, savePred = T)
model <- train(RT..seconds.~., data=lipids, method = "lmStepAIC", trControl = ctrl)

I want to be able to look at each the values of all my predicted and observed values as you would get when you do the function:-

model$pred

but it prints out all the folds and repeats for all the different C values (three of them), which doesn't all fit in the screen of R.

Is there way I can modify the function so that it only prints out the predicted results from each of the folds in the 10 repeats for when C is just equal to 0.5?

So something like this:-

      pred     obs rowIndex   .C     Resample
1 5011.101 5043.84        7 0.25 Fold01.Rep01
2 5120.894 5137.26        8 0.25 Fold01.Rep01
3 4915.161 5099.54       16 0.25 Fold01.Rep01
4 2778.198 2648.83       44 0.25 Fold01.Rep01
5 2894.722 2748.75       62 0.25 Fold01.Rep01
6 3334.751 3040.00       63 0.25 Fold01.Rep01

But just for when .C is 0.5, as at the moment it's printing for when .C is also 0.25 and 1

Thanks

Foi útil?

Solução

You want to check out the best and oneSE functions in caret.

I think the simplest way to make it return just the "best" is to modify your example above...

model <- train(RT..seconds.~., data=lipids, method = "lmStepAIC", trControl = ctrl, selectionFunction= "best")

This should work for your example (I hope) as the best default arguments are just the model with "best" RMSE - of anything more complicated see: help(oneSE)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top