CoverTree | R Documentation |
Wrapper R6 Class of FNN::get.knnx function that can be used for LESSRegressor and LESSClassifier
The cover tree is O(n) space data structure which allows us to answer queries in the same O(log(n)) time as kd tree given a fixed intrinsic dimensionality. Templated code from https://hunch.net/~jl/projects/cover_tree/cover_tree.html is used.
R6 Class of CoverTree
new()
Creates a new instance of R6 Class of CoverTree
CoverTree$new(X = NULL)
X
An M x d data.frame or matrix, where each of the M rows is a point or a (column) vector (where d=1).
data(abalone) ct <- CoverTree$new(abalone[1:100,])
query()
Finds the p number of near neighbours for each point in an input/output dataset.
CoverTree$query(query_X = private$X, k = 1)
query_X
A set of N x d points that will be queried against X
. d, the number of columns, must be the same as X
.
If missing, defaults to X
.
k
The maximum number of nearest neighbours to compute (deafults to 1).
A list
of length 2 with elements:
nn.idx | A N x k integer matrix returning the near neighbour indices. |
nn.dists | A N x k matrix returning the near neighbour Euclidean distances |
res <- ct$query(abalone[1:3,], k=2) print(res)
clone()
The objects of this class are cloneable with this method.
CoverTree$clone(deep = FALSE)
deep
Whether to make a deep clone.
FNN::get.knnx()
## ------------------------------------------------ ## Method `CoverTree$new` ## ------------------------------------------------ data(abalone) ct <- CoverTree$new(abalone[1:100,]) ## ------------------------------------------------ ## Method `CoverTree$query` ## ------------------------------------------------ res <- ct$query(abalone[1:3,], k=2) print(res)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.