Metric tree of nested hyperspheres, pruned by the triangle inequality. Pays off on data with real cluster structure at moderate dimensionality. The default search budget (5% of the indexed points) makes it approximate; raise it for recall. Past about 10% recall plateaus and query time does not fall. No Manhattan.
References
Omohundro SM (1989). Five balltree construction algorithms. Technical Report TR-89-063, International Computer Science Institute, Berkeley.
Super class
AnnIndex -> BallTreeIndex
Methods
Inherited methods
BallTreeIndex$new()
Build the index.
Usage
BallTreeIndex$new(
data,
metric = c("euclidean", "sqeuclidean", "cosine"),
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").search_budgetInteger or
NULL. Points inspected per query.NULLuses 5% of the indexed points. Can be changed after the build.seedInteger. Fixes the pivot choice at each split.
precisionString.
"float"stores the data as f32,"double"as f64.
Examples
x <- generate_clustered_data(1000L, 16L)$data
idx <- BallTreeIndex$new(x)
res <- idx$predict(x[1:5, ], k = 10L)
