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 | |
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.
| typedef AbstractNearestNeighbors<InputType,LabelType> shark::NearestNeighborModel< InputType, LabelType >::NearestNeighbors |
Definition at line 197 of file NearestNeighborModel.h.
| 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.
|
inline |
Constructor.
| algorithm | the used algorithm for nearest neighbor search |
| neighbors | number of neighbors |
Definition at line 210 of file NearestNeighborModel.h.
|
inline |
query the way distances enter as weights
Definition at line 219 of file NearestNeighborModel.h.
References shark::NearestNeighborModel< InputType, LabelType >::ONE_OVER_DISTANCE, and shark::NearestNeighborModel< InputType, LabelType >::UNIFORM.
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 215 of file NearestNeighborModel.h.
|
inline |
set the way distances enter as weights
Definition at line 224 of file NearestNeighborModel.h.
References shark::NearestNeighborModel< InputType, LabelType >::UNIFORM.