Description Usage Arguments Details Author(s) Examples
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.
1 2 |
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 |
plot.cor |
If |
... |
Additional arguments to |
Colour code:
rediris setosa
greeniris versicolour
blueiris virginica
blackquery
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)
.
phil
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.