knnDecision: Classification Decision Boundary

Description Usage Arguments Value Author(s) Examples

Description

Decision boundary of the fastknn classifier.

Usage

1
2
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.

Author(s)

David Pinto.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## 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)

## End(Not run)

davpinto/fastknn documentation built on May 15, 2019, 1:18 a.m.