knncolle_annoy
Annoy nearest neighbors in knncolle
Loading...
Searching...
No Matches
Public Member Functions | List of all members
knncolle_annoy::AnnoyBuilder< Distance_, Matrix_, Float_, InternalIndex_, InternalData_ > Class Template Reference

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

#include <knncolle_annoy.hpp>

Inheritance diagram for knncolle_annoy::AnnoyBuilder< Distance_, Matrix_, Float_, InternalIndex_, InternalData_ >:
knncolle::Builder< class Matrix_, typename Float_ >

Public Member Functions

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

Detailed Description

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.

Constructor & Destructor Documentation

◆ AnnoyBuilder() [1/2]

template<class Distance_ = Annoy::Euclidean, class Matrix_ = knncolle::SimpleMatrix<int, int, double>, typename Float_ = double, typename InternalIndex_ = typename Matrix_::index_type, typename InternalData_ = float>
knncolle_annoy::AnnoyBuilder< Distance_, Matrix_, Float_, InternalIndex_, InternalData_ >::AnnoyBuilder ( AnnoyOptions  options)
inline
Parameters
optionsFurther options for Annoy index construction and searching.

◆ AnnoyBuilder() [2/2]

template<class Distance_ = Annoy::Euclidean, class Matrix_ = knncolle::SimpleMatrix<int, int, double>, typename Float_ = double, typename InternalIndex_ = typename Matrix_::index_type, typename InternalData_ = float>
knncolle_annoy::AnnoyBuilder< Distance_, Matrix_, Float_, InternalIndex_, InternalData_ >::AnnoyBuilder ( )
default

Default constructor.

Member Function Documentation

◆ build_raw()

template<class Distance_ = Annoy::Euclidean, class Matrix_ = knncolle::SimpleMatrix<int, int, double>, typename Float_ = double, typename InternalIndex_ = typename Matrix_::index_type, typename InternalData_ = float>
knncolle::Prebuilt< typename Matrix_::dimension_type, typename Matrix_::index_type, Float_ > * knncolle_annoy::AnnoyBuilder< Distance_, Matrix_, Float_, InternalIndex_, InternalData_ >::build_raw ( const Matrix_ data) const
inlinevirtual

◆ get_options()

template<class Distance_ = Annoy::Euclidean, class Matrix_ = knncolle::SimpleMatrix<int, int, double>, typename Float_ = double, typename InternalIndex_ = typename Matrix_::index_type, typename InternalData_ = float>
AnnoyOptions & knncolle_annoy::AnnoyBuilder< Distance_, Matrix_, Float_, InternalIndex_, InternalData_ >::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: