knncolle_annoy
Annoy nearest neighbors in knncolle
Loading...
Searching...
No Matches
knncolle_annoy::AnnoyBuilder< Index_, Data_, Distance_, AnnoyDistance_, AnnoyIndex_, AnnoyData_, AnnoyRng_, AnnoyThreadPolicy_, Matrix_ > Class Template Reference

Perform an approximate nearest neighbor search with Annoy. More...

#include <knncolle_annoy.hpp>

Inheritance diagram for knncolle_annoy::AnnoyBuilder< Index_, Data_, Distance_, AnnoyDistance_, AnnoyIndex_, AnnoyData_, AnnoyRng_, AnnoyThreadPolicy_, Matrix_ >:
knncolle::Builder< typename Index_, typename Data_, typename Distance_, class Matrix_ >

Public Member Functions

 AnnoyBuilder (AnnoyOptions options)
 
 AnnoyBuilder ()=default
 
AnnoyOptionsget_options ()
 
knncolle::Prebuilt< Index_, Data_, Distance_ > * build_raw (const Matrix_ &data) const
 
- Public Member Functions inherited from knncolle::Builder< typename Index_, typename Data_, typename Distance_, class Matrix_ >
std::shared_ptr< Prebuilt< Index_, Data_, Distance_ > > build_shared (const Matrix_ &data) const
 
std::unique_ptr< Prebuilt< Index_, Data_, Distance_ > > build_unique (const Matrix_ &data) const
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ AnnoyBuilder() [1/2]

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_annoy::AnnoyBuilder< Index_, Data_, Distance_, AnnoyDistance_, AnnoyIndex_, AnnoyData_, AnnoyRng_, AnnoyThreadPolicy_, Matrix_ >::AnnoyBuilder ( AnnoyOptions options)
inline
Parameters
optionsFurther options for Annoy index construction and searching.

◆ AnnoyBuilder() [2/2]

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_annoy::AnnoyBuilder< Index_, Data_, Distance_, AnnoyDistance_, AnnoyIndex_, AnnoyData_, AnnoyRng_, AnnoyThreadPolicy_, Matrix_ >::AnnoyBuilder ( )
default

Default constructor.

Member Function Documentation

◆ build_raw()

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

◆ get_options()

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_>>
AnnoyOptions & knncolle_annoy::AnnoyBuilder< Index_, Data_, Distance_, AnnoyDistance_, AnnoyIndex_, AnnoyData_, AnnoyRng_, AnnoyThreadPolicy_, Matrix_ >::get_options ( )
inline
Returns
Options to the Annoy algorithm, to be modified prior to calling build_raw() and friends.

The documentation for this class was generated from the following file: