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. More...
 
std::string name () const
 From INameable: return the class name. More...
 
DistanceWeights getDistanceWeightType () const
 query the way distances enter as weights More...
 
void setDistanceWeightType (DistanceWeights dw)
 set the way distances enter as weights More...
 

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 192 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 195 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 199 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 208 of file NearestNeighborModel.h.

Member Function Documentation

◆ getDistanceWeightType()

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

query the way distances enter as weights

Definition at line 217 of file NearestNeighborModel.h.

◆ 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 213 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 222 of file NearestNeighborModel.h.


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