KDTree | R Documentation |
Wrapper R6 Class of RANN::nn2 function that can be used for LESSRegressor and LESSClassifier
R6 Class of KDTree
new()
Creates a new instance of R6 Class of KDTree
KDTree$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) kdt <- KDTree$new(abalone[1:100,])
query()
Finds the p number of near neighbours for each point in an input/output dataset. The advantage of the kd-tree is that it runs in O(M log M) time.
KDTree$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 <- kdt$query(abalone[1:3,], k=2) print(res)
clone()
The objects of this class are cloneable with this method.
KDTree$clone(deep = FALSE)
deep
Whether to make a deep clone.
RANN::nn2()
## ------------------------------------------------ ## Method `KDTree$new` ## ------------------------------------------------ data(abalone) kdt <- KDTree$new(abalone[1:100,]) ## ------------------------------------------------ ## Method `KDTree$query` ## ------------------------------------------------ res <- kdt$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.