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

NearestNeighbor model for classification and regression. More...

#include <shark/Models/NearestNeighborModel.h>

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

Public Types

enum  DistanceWeights { UNIFORM , ONE_OVER_DISTANCE }
 Type of distance-based weights. More...
 
typedef AbstractNearestNeighbors< InputType, LabelType > NearestNeighbors
 

Public Member Functions

 NearestNeighborModel (NearestNeighbors const *algorithm, unsigned int neighbors=3)
 Constructor.
 
std::string name () const
 From INameable: return the class name.
 
DistanceWeights getDistanceWeightType () const
 query the way distances enter as weights
 
void setDistanceWeightType (DistanceWeights dw)
 set the way distances enter as weights
 

Detailed Description

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

NearestNeighbor model for classification and regression.

The classification, the model predicts a class label according to a local majority decision among its k nearest neighbors. It is not specified how ties are broken.

For Regression, the (weighted) mean of the k nearest neighbours is computed.

Definition at line 194 of file NearestNeighborModel.h.

Member Typedef Documentation

◆ NearestNeighbors

template<class InputType , class LabelType >
typedef AbstractNearestNeighbors<InputType,LabelType> shark::NearestNeighborModel< InputType, LabelType >::NearestNeighbors

Definition at line 197 of file NearestNeighborModel.h.

Member Enumeration Documentation

◆ DistanceWeights

template<class InputType , class LabelType >
enum shark::NearestNeighborModel::DistanceWeights

Type of distance-based weights.

Enumerator
UNIFORM 

uniform (= no) distance-based weights

ONE_OVER_DISTANCE 

weight each neighbor's label with 1/distance

Definition at line 201 of file NearestNeighborModel.h.

Constructor & Destructor Documentation

◆ NearestNeighborModel()

template<class InputType , class LabelType >
shark::NearestNeighborModel< InputType, LabelType >::NearestNeighborModel ( NearestNeighbors const *  algorithm,
unsigned int  neighbors = 3 
)
inline

Constructor.

Parameters
algorithmthe used algorithm for nearest neighbor search
neighborsnumber of neighbors

Definition at line 210 of file NearestNeighborModel.h.

Member Function Documentation

◆ getDistanceWeightType()

template<class InputType , class LabelType >
DistanceWeights shark::NearestNeighborModel< InputType, LabelType >::getDistanceWeightType ( ) const
inline

◆ name()

template<class InputType , class LabelType >
std::string shark::NearestNeighborModel< InputType, LabelType >::name ( ) const
inlinevirtual

From INameable: return the class name.

Reimplemented from shark::INameable.

Definition at line 215 of file NearestNeighborModel.h.

◆ setDistanceWeightType()

template<class InputType , class LabelType >
void shark::NearestNeighborModel< InputType, LabelType >::setDistanceWeightType ( DistanceWeights  dw)
inline

set the way distances enter as weights

Definition at line 224 of file NearestNeighborModel.h.

References shark::NearestNeighborModel< InputType, LabelType >::UNIFORM.


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