1

There is a set of data with one label to classify each row. such as:

class x1  x2
1     1   3
1     4   5
2     7   0
2     8   11

I try to compute precision, recall, and accuracy of classification with 10-fold cross validation, but I do not know how. Can anyone teach me how to do it?

I tried to use CVTool, such as

k <- 10 #the number of folds

folds <- cvFolds(NROW(dataset), K=k)

for(i in 1:k){
       train <- dataset[folds$subsets[folds$which != i], ] 
       validation <- dataset[folds$subsets[folds$which == i], ]
       fit <- lm(class~.,train) 
       pred <- predict(fit,test) 

}

, but I do not know how to go on.There is an error:

 Error in prediction(fit, test) : 
  Number of cross-validation runs must be equal for predictions and labels.

Is there anyone can help me with that?

cecilia_z
  • 3
  • 4

0 Answers0