#include <Classifier.h>
Inheritance diagram for prapi::kNNClassifier< T, I, C >:

This classifier takes k nearest neighbors to a sample, according to a given proximity measure. The classification result is the class that has the majority in the k nearest neighbors. If there is a draw between two classes, then the closest one wins. If k equals to one, the classifier functions exactly as a nearest neighbor classifier does.
Public Methods | |
| kNNClassifier (util::List< Sample< T, I, C > > *trainingSamples, ProximityMeasure< T > *measure, int classCount, int k=1) | |
| Create a new kNN classifier with the given training samples, proximity measure, class count and k. | |
| kNNClassifier (util::List< Sample< T, I, C > > &trainingSamples, ProximityMeasure< T > *measure, int classCount, int k=1) | |
| Create a new kNN classifier with the given training samples, proximity measure, class count and k. | |
| kNNClassifier (util::List< Sample< T, I, C > > &trainingSamples, ProximityMeasure< T > &measure, int classCount, int k=1) | |
| Create a new kNN classifier with the given training samples, proximity measure, class count and k. | |
| C | getClassification (Sample< T, I, C > &sample) throw (ClassificationException&) |
| Get the classification for a single sample. | |
| void | setk (int newk) |
| Set a new value for k. | |
| int | getk (void) |
| Get the value of k. | |
|
||||||||||||||||||||||||
|
Create a new kNN classifier with the given training samples, proximity measure, class count and k. (Autorelease measure.) |
|
||||||||||||||||||||||||
|
Create a new kNN classifier with the given training samples, proximity measure, class count and k. (Autorelease measure.) |
|
||||||||||
|
Get the classification for a single sample. This method is used by holdOut and leaveOneOut to classify each sample. Subclasses must override this method.
Implements prapi::Classifier< T, I, C >. |
|
||||||||||
|
Set a new value for k. K is always ensured to be odd. That is, the least significant bit of k will always be turned on. |