Skip to main content
deleted 4 characters in body
Source Link
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$Regiontestset$Region, 
    predict(tree.1, newdata=testset, type="class"))

#Accuracy for each fold
Accuracy[i] = sum(diag(testtable))/length(testset[,1])

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])

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

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

#Accuracy for each fold
Accuracy[i] = sum(diag(testtable))/length(testset[,1])
Source Link
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])