I'm trying to make a k-fold CV for several classification methods/hiperparameters using the data available at
This set is made of 208 rows, each with 60 attributes. I'm reading it into a data.frame using the read.table function.
The next step is to split my data into k folds, let's say k = 5. My first attempt was to use
test <- createFolds(t, k=5)
I had two issues with this. The first one is that the lengths of the folds are not next to each other:
Length Class Mode
Fold1 29 -none- numeric
Fold2 14 -none- numeric
Fold3 7 -none- numeric
Fold4 5 -none- numeric
Fold5 5 -none- numeric
The other one is that this apparently splitted my data according to the attributes indexes, but I want to split the data itself. I thought that by transposing my data.frame, using:
test <- t(myDataNumericValues)
But when I call the createFolds function, it gives me something like this:
Length Class Mode
Fold1 2496 -none- numeric
Fold2 2496 -none- numeric
Fold3 2495 -none- numeric
Fold4 2496 -none- numeric
Fold5 2497 -none- numeric
The length issue was solved, but it's still not splitting my 208 data accordingly.
Any thoughts about what I can do? Do you think that the caret package is not the most appropriated?
Thanks in advance
Please read
?createFolds
to understand what the function does. It creates the indices that define which data are held out the separate folds (see the options to return the converse):To use these to split the data:
The function
train
is used in this package to do the actual modeling (you don't usually need to do the splitting yourself. See this page).Max
I'm not familiar with the
caret
package, but I used to write a function calculating CV based on decision tree from therpart
package. Of course, the function needs motifying in order to suit your purpose.}