visualise: Produce a visualisation of a k-nearest neighbours.

Description Usage Arguments Details Author(s) Examples

Description

Given a query, it's resulting neighbours and the original feature space, this function will plot a visualisation of the position of the query in relation to it's neighbours in the feature space.

Usage

1
2
visualise(feature.space, class.name, query = NULL, neighbours = NULL,
  plot.hist = F, plot.cor = F, ...)

Arguments

feature.space

The feature space.

class.name

The class name. E.g., species.

query

The query (optional).

neighbours

The resulting k-nearest neighbours (optional).

plot.hist

If TRUE plot a feature distribution histogram.

plot.cor

If TRUE plot feature correlation.

...

Additional arguments to pairs plotting function.

Details

Colour code:

The visualisation makes use of R's pairs plotting function, more information on which can be viewed in the function's man page: help(pairs).

Author(s)

phil

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# plot all the data.
visualise(iris.data, class.name="species", main="iris data", plot.hist=TRUE,
    plot.cor=TRUE)

# do not plot the first 2 features and omit the histogram+correlation plots.
visualise(iris.data[, -(1:2)], class.name="species", main="iris data")

#### visualise k-nearest neighbours.

# form a query.
q <- list(
    sepal.length=5.84,
    sepal.width=3.05,
    petal.length=3.76,
    petal.width=1.20)

# get the 10-nearest neighbours
top.10 <- knn(q, iris.data, 10)

# visualise the neighbours and query point.
visualise(iris.data, class.name="species", query=q, neighbours=top.10,
    main="iris data neighbours", plot.hist=TRUE, plot.cor=FALSE)

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