Description Usage Arguments Value References See Also Examples
Multiedit for k-NN classifier
1 |
x |
matrix of training set. |
class |
vector of classification of training set. |
k |
number of neighbours used in k-NN. |
V |
divide training set into V parts. |
I |
number of null passes before quitting. |
trace |
logical for statistics at each pass. |
Index vector of cases to be retained.
P. A. Devijver and J. Kittler (1982) Pattern Recognition. A Statistical Approach. Prentice-Hall, p. 115.
Ripley, B. D. (1996) Pattern Recognition and Neural Networks. Cambridge.
Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth edition. Springer.
1 2 3 4 5 6 7 8 9 10 11 12 | 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))
ind1 <- multiedit(train, cl, 3)
length(ind1)
table(cl, knn(train[ind1, , drop=FALSE], test, cl[ind1], 1))
ntrain <- train[ind1,]; ncl <- cl[ind1]
ind2 <- condense(ntrain, ncl)
length(ind2)
table(cl, knn(ntrain[ind2, , drop=FALSE], test, ncl[ind2], 1))
|
cl s c v
s 25 0 0
c 0 23 2
v 0 1 24
pass 1 size 70
pass 2 size 67
pass 3 size 67
pass 4 size 64
pass 5 size 62
pass 6 size 62
pass 7 size 62
pass 8 size 62
pass 9 size 62
[1] 62
cl s c v
s 25 0 0
c 0 18 7
v 0 1 24
[1] 43
[1] 36 43
[1] 16 36 43
[1] 16 31 36 43
[1] 16 31 36 43 62
[1] 16 31 36 43 52 62
[1] 6
cl s c v
s 25 0 0
c 0 17 8
v 0 0 25
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.