Aliases: multiedit
Keywords: classif
### ** Examples tr <- sample(1:50, 25) train <- rbind(iris3[tr,,1], iris3[tr,,2], iris3[tr,,3]) test <- rbind(iris3[-tr,,1], iris3[-tr,,2], iris3[-tr,,3]) cl <- factor(c(rep(1,25),rep(2,25), rep(3,25)), labels=c("s", "c", "v")) table(cl, knn(train, test, cl, 3))
cl s c v s 25 0 0 c 0 23 2 v 0 2 23
ind1 <- multiedit(train, cl, 3)
length(ind1)
[1] 47
table(cl, knn(train[ind1, , drop=FALSE], test, cl[ind1], 1))
cl s c v s 25 0 0 c 0 25 0 v 0 25 0
ntrain <- train[ind1,]; ncl <- cl[ind1] ind2 <- condense(ntrain, ncl)
[1] 18 [1] 18 47
length(ind2)
[1] 2
table(cl, knn(ntrain[ind2, , drop=FALSE], test, ncl[ind2], 1))
cl s c v s 25 0 0 c 0 25 0 v 0 25 0