knn: K-Nearest-Neighbors.

Description Usage Arguments Value Author(s) Examples

Description

Implementation of the k-NN method.

Usage

1
knn(query, feature.space, k = 1, d.fun = euclidean)

Arguments

query

A list of labeled parameters to query for.

feature.space

The feature space to query against.

k

The k nearest neighbours to return. Default: 1.

d.fun

The distance function to use. Default: euclidean.

Value

The top k nearest neighours in the feature space with respect to the query.

Author(s)

phil

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# form the query instance.
query <- list(
    sepal.length=5.84,
    sepal.width=3.05,
    petal.length=3.76,
    petal.width=1.20)

# obtain the nearest-neighbour
top.1 <- knn(query, iris.data, 1)
print(top.1, row.names=FALSE)

phil8192/lazy-iris documentation built on May 25, 2019, 2:56 a.m.