shark::SimpleNearestNeighbors< InputType, LabelType > Class Template Reference

Brute force optimized nearest neighbor implementation. More...

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

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

Public Types

typedef LabeledData< InputType, LabelType > Dataset
 
typedef AbstractMetric< InputTypeMetric
 
typedef base_type::DistancePair DistancePair
 
typedef Batch< InputType >::type BatchInputType
 
- Public Types inherited from shark::AbstractNearestNeighbors< InputType, LabelType >
typedef KeyValuePair< double, LabelType > DistancePair
 
typedef Batch< InputType >::type BatchInputType
 

Public Member Functions

 SimpleNearestNeighbors (Dataset const &dataset, Metric const *metric)
 Constructor. More...
 
std::vector< DistancePairgetNeighbors (BatchInputType const &patterns, std::size_t k) const
 Return the k nearest neighbors of the query point. More...
 
LabeledData< InputType, LabelType > const & dataset () const
 Direct access to the underlying data set of nearest neighbor points. More...
 
- Public Member Functions inherited from shark::AbstractNearestNeighbors< InputType, LabelType >
Shape const & inputShape () const
 Returns the expected shape of the inputs. More...
 
virtual ~AbstractNearestNeighbors ()
 

Additional Inherited Members

- Protected Attributes inherited from shark::AbstractNearestNeighbors< InputType, LabelType >
Shape m_inputShape
 

Detailed Description

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

Brute force optimized nearest neighbor implementation.

Returns the labels and distances of the k nearest neighbors of a point The distance is measured using an arbitrary metric

Definition at line 51 of file SimpleNearestNeighbors.h.

Member Typedef Documentation

◆ BatchInputType

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

Definition at line 58 of file SimpleNearestNeighbors.h.

◆ Dataset

template<class InputType, class LabelType>
typedef LabeledData<InputType, LabelType> shark::SimpleNearestNeighbors< InputType, LabelType >::Dataset

Definition at line 55 of file SimpleNearestNeighbors.h.

◆ DistancePair

template<class InputType, class LabelType>
typedef base_type::DistancePair shark::SimpleNearestNeighbors< InputType, LabelType >::DistancePair

Definition at line 57 of file SimpleNearestNeighbors.h.

◆ Metric

template<class InputType, class LabelType>
typedef AbstractMetric<InputType> shark::SimpleNearestNeighbors< InputType, LabelType >::Metric

Definition at line 56 of file SimpleNearestNeighbors.h.

Constructor & Destructor Documentation

◆ SimpleNearestNeighbors()

template<class InputType, class LabelType>
shark::SimpleNearestNeighbors< InputType, LabelType >::SimpleNearestNeighbors ( Dataset const &  dataset,
Metric const *  metric 
)
inline

Constructor.

Construct a "brute force" nearest neighbors search algorithm
from data and a metric. Refer to the AbstractMetric class for details. The "default" Euclidean metric is realized by providing a pointer to an object of type LinearKernel<InputType>.

Definition at line 66 of file SimpleNearestNeighbors.h.

References shark::LabeledData< InputT, LabelT >::inputShape(), and shark::AbstractNearestNeighbors< InputType, LabelType >::m_inputShape.

Member Function Documentation

◆ dataset()

template<class InputType, class LabelType>
LabeledData<InputType,LabelType> const& shark::SimpleNearestNeighbors< InputType, LabelType >::dataset ( ) const
inlinevirtual

Direct access to the underlying data set of nearest neighbor points.

Implements shark::AbstractNearestNeighbors< InputType, LabelType >.

Definition at line 138 of file SimpleNearestNeighbors.h.

◆ getNeighbors()

template<class InputType, class LabelType>
std::vector<DistancePair> shark::SimpleNearestNeighbors< InputType, LabelType >::getNeighbors ( BatchInputType const &  patterns,
std::size_t  k 
) const
inlinevirtual

Return the k nearest neighbors of the query point.

Implements shark::AbstractNearestNeighbors< InputType, LabelType >.

Definition at line 72 of file SimpleNearestNeighbors.h.

References shark::batchSize().


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