shark::AbstractNearestNeighbors< InputType, LabelType > Class Template Referenceabstract

Interface for Nearest Neighbor queries. More...

#include <shark/Algorithms/NearestNeighbors/AbstractNearestNeighbors.h>

+ Inheritance diagram for shark::AbstractNearestNeighbors< InputType, LabelType >:

Public Types

typedef KeyValuePair< double, LabelType > DistancePair
 
typedef Batch< InputType >::type BatchInputType
 

Public Member Functions

virtual std::vector< DistancePairgetNeighbors (BatchInputType const &batch, std::size_t k) const =0
 Returns the k-nearest neighbors of a batch of points and returns them as linearized array. More...
 
Shape const & inputShape () const
 Returns the expected shape of the inputs. More...
 
virtual LabeledData< InputType, LabelType > const & dataset () const =0
 returns a const reference to the dataset used by the algorithm More...
 
virtual ~AbstractNearestNeighbors ()
 

Protected Attributes

Shape m_inputShape
 

Detailed Description

template<class InputType, class LabelType>
class shark::AbstractNearestNeighbors< InputType, LabelType >

Interface for Nearest Neighbor queries.

Defines the abstract interface for query of nearest neighbors. This is used to generalize over the different algorithms to query for nearest neighbors.

Definition at line 48 of file AbstractNearestNeighbors.h.

Member Typedef Documentation

◆ BatchInputType

template<class InputType , class LabelType >
typedef Batch<InputType>::type shark::AbstractNearestNeighbors< InputType, LabelType >::BatchInputType

Definition at line 51 of file AbstractNearestNeighbors.h.

◆ DistancePair

template<class InputType , class LabelType >
typedef KeyValuePair<double,LabelType> shark::AbstractNearestNeighbors< InputType, LabelType >::DistancePair

Definition at line 50 of file AbstractNearestNeighbors.h.

Constructor & Destructor Documentation

◆ ~AbstractNearestNeighbors()

template<class InputType , class LabelType >
virtual shark::AbstractNearestNeighbors< InputType, LabelType >::~AbstractNearestNeighbors ( )
inlinevirtual

Definition at line 67 of file AbstractNearestNeighbors.h.

Member Function Documentation

◆ dataset()

template<class InputType , class LabelType >
virtual LabeledData<InputType,LabelType> const& shark::AbstractNearestNeighbors< InputType, LabelType >::dataset ( ) const
pure virtual

◆ getNeighbors()

template<class InputType , class LabelType >
virtual std::vector<DistancePair> shark::AbstractNearestNeighbors< InputType, LabelType >::getNeighbors ( BatchInputType const &  batch,
std::size_t  k 
) const
pure virtual

Returns the k-nearest neighbors of a batch of points and returns them as linearized array.

Given a batch of size n, a array with nxk values is returned where each entry is a key-value pair of distance and label. the first k entries are the neighbors of point 1, the next k of point 2 and so on.

Implemented in shark::TreeNearestNeighbors< InputType, LabelType >, and shark::SimpleNearestNeighbors< InputType, LabelType >.

◆ inputShape()

template<class InputType , class LabelType >
Shape const& shark::AbstractNearestNeighbors< InputType, LabelType >::inputShape ( ) const
inline

Member Data Documentation

◆ m_inputShape


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