Interface for Nearest Neighbor queries. More...
#include <shark/Algorithms/NearestNeighbors/AbstractNearestNeighbors.h>
Public Types | |
typedef KeyValuePair< double, LabelType > | DistancePair |
typedef Batch< InputType >::type | BatchInputType |
Public Member Functions | |
virtual std::vector< DistancePair > | getNeighbors (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 |
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.
typedef Batch<InputType>::type shark::AbstractNearestNeighbors< InputType, LabelType >::BatchInputType |
Definition at line 51 of file AbstractNearestNeighbors.h.
typedef KeyValuePair<double,LabelType> shark::AbstractNearestNeighbors< InputType, LabelType >::DistancePair |
Definition at line 50 of file AbstractNearestNeighbors.h.
|
inlinevirtual |
Definition at line 67 of file AbstractNearestNeighbors.h.
|
pure virtual |
returns a const reference to the dataset used by the algorithm
Implemented in shark::TreeNearestNeighbors< InputType, LabelType >, and shark::SimpleNearestNeighbors< InputType, LabelType >.
Referenced by shark::AbstractNearestNeighbors< InputType, LabelType >::inputShape().
|
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 >.
|
inline |
Returns the expected shape of the inputs.
Definition at line 60 of file AbstractNearestNeighbors.h.
References shark::AbstractNearestNeighbors< InputType, LabelType >::dataset(), and shark::AbstractNearestNeighbors< InputType, LabelType >::m_inputShape.
|
protected |
Definition at line 69 of file AbstractNearestNeighbors.h.
Referenced by shark::AbstractNearestNeighbors< InputType, LabelType >::inputShape(), and shark::SimpleNearestNeighbors< InputType, LabelType >::SimpleNearestNeighbors().