Skip to main content
1 of 2
G5W
  • 2.7k
  • 1
  • 12
  • 25

It is almost the same as what you already have. You just need to specify the test data in your predict statement.

testtable <- table(trainingset$Region, 
    predict(tree.1, newdata=testset, type="class"))

#Accuracy for each fold
Accuracy[i] = sum(diag(testtable))/length(testset[,1])
G5W
  • 2.7k
  • 1
  • 12
  • 25