Description Usage Arguments Value Author(s) References See Also Examples

`kNN`

is used to perform k-nearest neighbour classification for test set using training set. For each row of the test set, the `k`

nearest (based on Euclidean distance) training set vectors are found. Then, the classification is done by majority vote (ties broken at random). This function provides a formula interface to the `knn`

function of `R`

package `class`

. In addition, it allows normalization of the given data using the `transform`

function.

1 2 |

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

`train` |
data frame or matrix of train set cases. |

`test` |
data frame or matrix of test set cases. |

`k` |
number of neighbours considered. |

`transform` |
a character with options |

`type` |
either |

`l` |
minimum vote for definite decision, otherwise |

`use.all` |
controls handling of ties. If true, all distances equal to the |

`na.rm` |
a logical value indicating whether NA values in |

When `type = "class"`

(default), a factor vector is returned,
in which the `doubt`

will be returned as `NA`

.
When `type = "prob"`

, a matrix of confidence values is returned
(one column per class).

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

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.

1 2 3 4 5 6 |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.