I tried to set a loop that could get specific values from a confusion matrix, but it was impossible for me.
This is the simple idea that I have in mind:
knn_MaC <- function(train,test,label,test_label,k,positive){
z <- matrix()
for (i in k){
Yp <- knn(train = train, test = test, cl= label,k = i)
MaC <- confusionMatrix(Yp,test_label,positive)
z <- c(MaC$table[2],MaC$table[3])
}}
As I said, I tried a lot of ways getting all kinds of errors instead. My idea is get this values to make a resume table.