kNN.plot: Visualizing the Optimal Number of k

Description Usage Arguments Author(s) References See Also Examples

View source: R/kNN.plot.R

Description

Visualizing the Optimal Number of k for k-Nearest Neighbour ClassificationkNN based on accuracy or Mean Square Error (MSE).

Usage

1
2
kNN.plot( formula, train, test, k.max = 10, transform = FALSE, base = "error", 
          set.seed = NULL, ... )

Arguments

formula

a formula, with a response but no interaction terms. For the case of data frame, it is taken as the model frame (see model.frame).

train

data frame or matrix of train set cases.

test

data frame or matrix of test set cases.

k.max

the maximum number of number of neighbours to consider, must be at least two.

transform

a character with options FALSE (default), "minmax", and "zscore". Option "minmax" means no transformation. This option allows the users to use normalized version of the train and test sets for the kNN aglorithm.

base

base measurement: error (default), accuracy, or MSE for Mean Square Error.

set.seed

a single value, interpreted as an integer, or NULL.

...

options to be passed to kNN().

Author(s)

Reza Mohammadi a.mohammadi@uva.nl and Kevin Burke kevin.burke@ul.ie

References

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.

See Also

kNN, transform

Examples

1
2
3
4
5
6
7
data( risk )

train = risk[   1:150, ]
test  = risk[ 151:246, ]

kNN.plot( risk ~ income + age, train = train, test = test )
kNN.plot( risk ~ income + age, train = train, test = test, base = "accuracy" )

liver documentation built on Oct. 27, 2021, 5:06 p.m.