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
Post a Comment