I'm trying to just extract the Accuracy value from the confusionMatrix() output -- I've tried using the following:
cl <- train.data[,1]
knn.res <- knn.cv(train.data[,c(2:783)], cl, k = i, algorithm = "cover_tree")
confus.knn.res <- confusionMatrix(knn.res, train.data[,1])
confus.knn.res
k.accuracy[which(k.accuracy[,2]==i),2] <- confus.knn.res$Accuracy
though just calling it as $Accuracy doesn't seem to work.
One of the values of confusionMatrix() object is overall -- the first index of overall is the accuracy value. Therefore, it can be called as confus.knn.res$overall[1].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With