yh_kNN: kNN or NN prediction

Description Usage Arguments Value Author(s) See Also Examples

View source: R/yh_kNN.R

Description

Given training data and test examples, the kNN predictions for the test data are produced. The tuning parameter k is automatically selected by specifying one of the methods: LOOCV, MLE or NN.

Usage

1
yh_kNN(dfTr, dfTe, method = c("LOOCV", "MLE", "NN"), k=1)

Arguments

dfTr

dataframe with last column for the output. The output must be a factor.

dfTe

dataframe for test data. Must have columns corresponding to the training columns except the test output is not needed.

method

One of the automatic methods for selecting k, the number of nearest neighbours. The default is LOOCV.

k

Pre-specified k but this value of k is only used when method="NN" otherwise when method="LOOCV" or method="MLE", k is estimated.

Value

The mis-classification rate (cost) and correlation of prediction and test.

Author(s)

A. I. McLeod

See Also

yh_C50, yh_CART, yh_RF, yh_svm, yh_NB, yh_lda, yh_logistic, yh_qda

Examples

1
2
yh_kNN(SinghTrain[,c(1:10, 101)], SinghTest[,c(1:10, 101)])#0.088
yh_kNN(SinghTrain[,c(1:10, 101)], SinghTest[,c(1:10, 101)], method="NN")#0.088

gencve documentation built on May 29, 2017, 7:12 p.m.