k-Nearest-Neighbors Search
An implementation of k-nearest-neighbor search using single-tree and dual-tree algorithms. Given a set of reference points and query points, this can find the k nearest neighbors in the reference set of each query point using trees.
Available Predicates
initAndBuildModel/10
Initialize the Model and build it.
%% part of the predicate definition
initAndBuildModel( +string, +string,
+integer,
+integer, +float32, +float32, +float32,
+pointer(float_array), +integer, +integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
treeType | +string | Type of tree to use: "kd", "vp", "rp", "max-rp", "ub", "cover", "r", "r-star", "x", "ball", "hilbert-r", "r-plus", "r-plus-plus", "spill", "oct". | kd |
searchMode | +string | Type of neighbor search: "naive", "single_tree", "dual_tree", "greedy". | dual_tree |
randomBasis | +integer(bool) | Before tree-building, project the data onto a random orthogonal basis. | (0)false |
leafSize | +integer | Leaf size for tree building. Not used by cover trees | 20 |
tau | +float | Overlapping size (only valid for spill trees). | 0.7 |
rho | +float | Balance threshold (only valid for spill trees). | 0.0 |
epsilon | +float | If specified, will do approximate furthest neighbor search with given relative error. Must be in the range [0,1). | 0.0 |
referenceSet | +matrix | Matrix containing the reference dataset. | - |
searchWithQuery/10
Perform neighbor search on the queryset.
%% part of the predicate definition
searchWithQuery( +pointer(float_array), +integer, +integer,
+integer,
-pointer(float_array), -integer, -integer,
-pointer(float_array), -integer, -integer)
Parameters
Name | Type | Description | Default |
---|---|---|---|
querySet | +matrix | Matrix containing query points (optional). | - |
k | +integer | Number of furthest neighbors to find. | 0 |
neighbors | -matrix | Matrix to output distances into. | - |
distances | -matrix | Matrix to output neighbors into. | - |
searchNoQuery/7
Perform monochromatic neighbor search.
%% part of the predicate definition
searchNoQuery( +integer,
-pointer(float_array), -integer, -integer,
-pointer(float_array), -integer, -integer)
Parameters
Name | Type | Description | Default |
---|---|---|---|
k | +integer | Number of furthest neighbors to find. | 0 |
neighbors | -matrix | Matrix to output distances into. | - |
distances | -matrix | Matrix to output neighbors into. | - |
Connected Links/Resources
If you want a more detailed explanation, then go to the python documentation. There is most of the time a good explanation on how the methods work and what the parameters do.
added some of the links from the python documentation