| knn_to_sparse | R Documentation |
Rows represent observations or queries and columns represent reference
observations. Set transpose = TRUE to reverse the axes. Missing neighbors
(idx = 0, dist = NA) are omitted. Stored zero distances are retained.
If a row contains the same neighbor more than once, the last stored distance
is used.
knn_to_sparse(graph, n_reference = nrow(graph$idx), transpose = FALSE)
graph |
A neighbor graph containing |
n_reference |
Number of reference observations. Supply this explicitly for query results when the reference size differs from the number of rows. |
transpose |
Whether to put reference observations in rows. |
A numeric dgCMatrix of distances.
graph <- brute_force_knn(iris[1:8, 1:4], k = 5)
knn_to_sparse(graph)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.