knn_dist | R Documentation |
knn_dist
searches for nearest neighbors in a dissimilarity matrix matrix.
knn_dist(D, K)
D |
Dissimilarity matrix of size (n,n), where n is the number of objects. |
K |
Number of neighbors |
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
.
A list with two components:
An (n,K) matrix for the nearest neighbor dissimilarities.
An (n,K) matrix for the nearest neighbor indices.
Thierry Denoeux.
get.knn
, EkNNclus
data(butterfly)
n <- nrow(butterfly)
D<-as.matrix(dist(butterfly))
knn<-knn_dist(D,K=2)
knn$nn.dist
knn$nn.index
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.