r - Creating Custom Folds For Caret CV -


i'm using caret package model , cross validate

model <- caret::train(mpg  ~ wt                            + drat                            + disp                            + qsec                            + as.factor(am),                   data = mtcars,                   method = "lm",                   trcontrol = caret::traincontrol(method = "cv",                                                 repeats=5,                                                 returndata =false)) 

however, i'd pass traincontrol custom set of indices relating folds. can done via indexout.

model <- caret::train(wt ~  + disp + drat,                   data = mtcars,                        method = "lm",                    trcontrol = caret::traincontrol(method = "cv",                                       returndata =false,                                       index = indicies$train,                                       indexout = indicies$test)) 

what i'm struggling want test on rows in mtcars mtcars.am==0. use of createfolds won't work because can't add criterion. know of other functions allow indexing of rows k-folds criterion of mtcars.am==0 can added in creating indicies$test?

i think should work. feed index desired row index.

index = list(which(mtcars$am == 0))  model <- caret::train(     wt ~  +disp + drat,     data = mtcars,     method = "lm",     trcontrol = caret::traincontrol(         method = "cv",         returndata = false,         index = index     ) ) 

index argument list can feed many iterations want list creating multiple nested list in index.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -