NearestNeighbor model for classification and regression. More...
#include <shark/Models/NearestNeighborModel.h>
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... | |
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.
typedef AbstractNearestNeighbors<InputType,LabelType> shark::NearestNeighborModel< InputType, LabelType >::NearestNeighbors |
Definition at line 195 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 199 of file NearestNeighborModel.h.
|
inline |
Constructor.
algorithm | the used algorithm for nearest neighbor search |
neighbors | number of neighbors |
Definition at line 208 of file NearestNeighborModel.h.
|
inline |
query the way distances enter as weights
Definition at line 217 of file NearestNeighborModel.h.
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 213 of file NearestNeighborModel.h.
|
inline |
set the way distances enter as weights
Definition at line 222 of file NearestNeighborModel.h.