knn_dist {evclust} | R Documentation |
K nearest neighbors in a dissimilarity matrix
Description
knn_dist
searches for nearest neighbors in a dissimilarity matrix matrix.
Usage
knn_dist(D, K)
Arguments
D |
Dissimilarity matrix of size (n,n), where n is the number of objects. |
K |
Number of neighbors |
Details
This function is called by EkNNclus
if argument x is not supplied.
It is not optimized and cannot be used for very large D. If an attribute matrix
x is supplied and D is the matrix of Euclidean distances, it is preferable to use
function get.knn
from package FNN
.
Value
A list with two components:
- nn.dist
An (n,K) matrix for the nearest neighbor dissimilarities.
- nn.index
An (n,K) matrix for the nearest neighbor indices.
Author(s)
Thierry Denoeux.
See Also
Examples
data(butterfly)
n <- nrow(butterfly)
D<-as.matrix(dist(butterfly))
knn<-knn_dist(D,K=2)
knn$nn.dist
knn$nn.index
[Package evclust version 2.0.3 Index]