I am using caret package in R for training dataset and cross validation process. I am confused about cross validation process.
Now, i am splitting the dataset to two subset, training and testing;
inTraining <- createDataPartition(dataset$class, p = .75, list = FALSE)
training <- dataset[ inTraining,]
testing <- dataset[-inTraining,]
After that, i am using the code below for training the model on training dataset;
fitControl_cv <- trainControl(## 10-fold CV
method = "cv",
number = 10,
verbose = TRUE)
model <- train(TRAINING$class ~ ., TRAINING, method = "<a_name>" ,trControl = fitControl_cv)
Is this true or not? I am confused why i am split dataset first. In my opinion, i don't need to split data to two subset, training and testing. Because, cross validation process is already doing that job, i guess.
This is my approach in R;
model <- train(DATASET$class ~ ., DATASET, method = "<a_name>" ,trControl = fitControl_cv)
Which one is true? Applying cross validation to whole dataset or training set?