| BootKNN | R Documentation | 
How to bootstrap with kNN (and DNN)
BootKNN(data, classes, sub="none", nsam=4, nboot=1000, misclass=TRUE, method="knn", ...)
data | 
 Data frame to classify  | 
classes | 
 Character vector of class names  | 
sub | 
 Subsample to use (see example)  | 
nsam | 
 Number of training items from each level of grouping factor, default 4  | 
nboot | 
 Number of iterations  | 
misclass | 
 Calculate misclassification table?  | 
method | 
 Either "knn" (class::knn()) or "dnn" (shipunov::Dnn())  | 
... | 
 Further arguments to method functions  | 
This function samples equal numbers ('nsam') of training items from each level of grouping factor.
It also allows to use subset of data which will be used for sub-sampling of training data.
Returns all predictions as character matrix, each boot is a column
Alexey Shipunov
class::knn, Dnn
iris.sub <- 1:nrow(iris) %in% seq(1, nrow(iris), 5) iris.bootknn <- BootKNN(iris[, -5], iris[, 5], sub=iris.sub) ## calculate and plot stability st <- apply(iris.bootknn, 1, function(.x) var(as.numeric(as.factor(.x)))) plot(prcomp(iris[, -5])$x, col=iris$Species, pch=ifelse(st == 0, 19, 1)) ## boot Dnn BootKNN(iris[, -5], iris[, 5], nboot=50, method="dnn", k=1, FUN=function(.x) Gower.dist(.x))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.