Decision boundary of the fastknn classifier.

knnDecision(xtr, ytr, xte, yte, k, method = "dist", normalize = NULL,
  dpi = 150)

Arguments

xtr
matrix containing the training instances. If xtr is not a bidimensional matrix only the first two columns will be considered.
ytr
factor array with the training labels.
xte
(optional) Matrix containing the test instances. The test points will be plotted over the surface boundary. If missing, the training points will be plotted instead. If xte is not a bidimensional matrix only the first two columns will be considered.
yte
(optional) Factor array with the test labels.
k
number of neighbors considered.
method
method used to infer the class membership probabilities of the test instances. See fastknn for more details.
normalize
variable scaler as in fastknn.
dpi
a scalar that defines the graph resolution (default = 150). It means that dpi^2 data points will be generated from the original dataset to draw the decision boundary. So, for large values (>= 300) it may take too much time to plot.

Value

ggplot2 object.

Examples

## Not run: ------------------------------------ # library("caTools") # library("fastknn") # # data("spirals") # # x <- data.matrix(spirals$x) # y <- spirals$y # # set.seed(2048) # tr.idx <- which(sample.split(Y = y, SplitRatio = 0.7)) # x.tr <- x[tr.idx,] # x.te <- x[-tr.idx,] # y.tr <- y[tr.idx] # y.te <- y[-tr.idx] # # knnDecision(xtr = x.tr, ytr = y.tr, xte = x.te, yte = y.te, k = 10) ## ---------------------------------------------