template<
class Distance_ = Annoy::Euclidean,
class Matrix_ = knncolle::SimpleMatrix<int, int, double>,
typename Float_ = double,
typename InternalIndex_ = typename Matrix_::index_type,
typename InternalData_ = float>
class knncolle_annoy::AnnoyBuilder< Distance_, Matrix_, Float_, InternalIndex_, InternalData_ >
Perform an approximate nearest neighbor search with Annoy.
In the Approximate Nearest Neighbors Oh Yeah (Annoy) algorithm, a tree is constructed where a random hyperplane splits the points into two subsets at each internal node. Leaf nodes are defined when the number of points in a subset falls below a threshold (close to twice the number of dimensions for the settings used here). Multiple trees are constructed in this manner, each of which is different due to the random choice of hyperplanes. For a given query point, each tree is searched to identify the subset of all points in the same leaf node as the query point. The union of these subsets across all trees is exhaustively searched to identify the actual nearest neighbors to the query.
- See also
- Bernhardsson E (2018). Annoy. https://github.com/spotify/annoy
- Template Parameters
-
Distance_ | An Annoy class to compute the distance between vectors, e.g., Annoy::Euclidean , Annoy::Manhattan . Note that this is not the same as knncolle::MockDistance . |
Matrix_ | Matrix-like object satisfying the knncolle::MockMatrix interface. |
Float_ | Floating point type for the query data and output distances. |
InternalIndex_ | Integer type for the internal indices in Annoy. |
InternalData_ | Floating point type for the internal data in Annoy. This defaults to a float instead of a double to sacrifice some accuracy for performance. |