Random projection forest, as in Spotify's Annoy. More trees means better
recall, a larger index and a slower build. Raise search_budget for recall
at query time. No Manhattan.
References
Bernhardsson E. Annoy (Approximate Nearest Neighbors Oh Yeah). https://github.com/spotify/annoy
Super class
AnnIndex -> AnnoyIndex
Methods
Inherited methods
AnnoyIndex$new()
Build the index.
Usage
AnnoyIndex$new(
data,
metric = c("euclidean", "sqeuclidean", "cosine"),
n_trees = 25L,
search_budget = NULL,
seed = 42L,
precision = c("float", "double")
)Arguments
dataNumeric matrix or data.frame. Samples x features. An index pointer is also accepted;
load_ann_index()uses that path.metricString. One of
c("euclidean", "sqeuclidean", "cosine").n_treesInteger. Number of trees in the forest.
search_budgetInteger or
NULL. Candidates inspected per query.NULLusesk * n_trees * 20. Can be changed after the build.seedInteger. Fixes the random hyperplanes.
precisionString.
"float"stores the data as f32,"double"as f64.
Examples
x <- generate_clustered_data(1000L, 16L)$data
idx <- AnnoyIndex$new(x, n_trees = 25L)
res <- idx$predict(x[1:5, ], k = 10L)
