| knn_distances | R Documentation |
Calculate distances for the supplied indices in their existing order. Rows
of idx correspond to observations, or to queries when query is supplied.
Indices always refer to observations in data. Missing indices (0) remain
paired with NA distances.
knn_distances(
data,
idx,
metric = "euclidean",
query = NULL,
n_threads = 0,
verbose = FALSE,
obs = "R"
)
data |
Reference observations, in a numeric matrix or data frame, a logical matrix, or a numeric sparse matrix. |
idx |
Numeric matrix of whole-number neighbor indices. For a graph,
pass |
metric |
Distance metric, evaluated directly. See |
query |
Optional query observations with the same feature layout as
|
n_threads |
Number of threads to use. Zero runs serially. |
verbose |
Whether to report progress. |
obs |
Whether observations are in rows ( |
A list containing the supplied idx and calculated dist matrices.
graph <- brute_force_knn(iris[1:8, 1:4], k = 5)
knn_distances(iris[1:8, 1:4], graph$idx, metric = "manhattan")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.