template<typename Index_, typename Data_, typename Distance_, class AnnoyDistance_, typename AnnoyIndex_ = Index_, typename AnnoyData_ = float, class AnnoyRng_ = Annoy::Kiss64Random, class AnnoyThreadPolicy_ = Annoy::AnnoyIndexSingleThreadedBuildPolicy, class Matrix_ = knncolle::Matrix<Index_, Data_>>
class knncolle_annoy::AnnoyBuilder< Index_, Data_, Distance_, AnnoyDistance_, AnnoyIndex_, AnnoyData_, AnnoyRng_, AnnoyThreadPolicy_, Matrix_ >
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
-
Index_ | Integer type for the observation indices. |
Data_ | Numeric type for the input and query data. |
Distance_ | Floating-point type for the distances. |
AnnoyDistance_ | An Annoy-compatible class to compute the distance between vectors, e.g., Annoy::Euclidean , Annoy::Manhattan . Note that this is not the same as knncolle::DistanceMetric . |
AnnoyIndex_ | Integer type for the observation indices in the Annoy index. |
AnnoyData_ | Floating-point type for data in the Annoy index. This defaults to a float instead of a double to sacrifice some accuracy for performance. |
AnnoyRng_ | An Annoy class for random number generation. |
AnnoyThreadPolicy_ | An Annoy class for the threadedness of Annoy index building. |
Matrix_ | Class of the input data matrix. This should satisfy the knncolle::Matrix interface. |
template<typename Index_ , typename Data_ , typename Distance_ , class AnnoyDistance_ , typename AnnoyIndex_ = Index_, typename AnnoyData_ = float, class AnnoyRng_ = Annoy::Kiss64Random, class AnnoyThreadPolicy_ = Annoy::AnnoyIndexSingleThreadedBuildPolicy, class Matrix_ = knncolle::Matrix<Index_, Data_>>
knncolle::Prebuilt< Index_, Data_, Distance_ > * knncolle_annoy::AnnoyBuilder< Index_, Data_, Distance_, AnnoyDistance_, AnnoyIndex_, AnnoyData_, AnnoyRng_, AnnoyThreadPolicy_, Matrix_ >::build_raw |
( |
const Matrix_ & | data | ) |
const |
|
inlinevirtual |