#include <knnClassification.h>


Public Member Functions | |
| knnClassification (const int &num_inputs, const std::vector< int > &which_inputs, const std::vector< trainingExampleTemplate< T > > &trainingSet, const int k) | |
| ~knnClassification () | |
| void | addNeighbour (const int &classNum, const std::vector< T > &features) |
| T | run (const std::vector< T > &inputVector) |
| void | train (const std::vector< trainingExampleTemplate< T > > &trainingSet) |
| void | reset () |
| int | getNumInputs () const |
| std::vector< int > | getWhichInputs () const |
| int | getK () const |
| void | setK (int newK) |
| void | getJSONDescription (Json::Value ¤tModel) |
Public Member Functions inherited from baseModel< T > | |
| virtual | ~baseModel () |
Additional Inherited Members | |
Protected Member Functions inherited from baseModel< T > | |
| template<typename TT > | |
| Json::Value | vector2json (TT vec) |
Class for implementing a knn classifier
| knnClassification< T >::knnClassification | ( | const int & | num_inputs, |
| const std::vector< int > & | which_inputs, | ||
| const std::vector< trainingExampleTemplate< T > > & | trainingSet, | ||
| const int | k | ||
| ) |
Constructor that takes training examples in
| number | of inputs expected in the training and input vectors |
| vector | of input numbers to be fed into the classifer. |
| vector | of training examples |
| how | many near neighbours to evaluate |
| knnClassification< T >::~knnClassification | ( | ) |
| void knnClassification< T >::addNeighbour | ( | const int & | classNum, |
| const std::vector< T > & | features | ||
| ) |
add another example to the existing training set
| class | number of example |
| feature | vector of example |
|
virtual |
Populate a JSON value with a description of the current model
| A | JSON value to be populated |
Implements baseModel< T >.
| int knnClassification< T >::getK | ( | ) | const |
Get the number of nearest neighbours used by the kNN algorithm.
|
virtual |
Find out how many inputs the model expects
Implements baseModel< T >.
|
virtual |
Find out which inputs in a vector will be used
Implements baseModel< T >.
|
virtual |
Reset the model to its empty state.
Implements baseModel< T >.
|
virtual |
Generate an output value from a single input vector.
| A | standard vector of type T to be evaluated. |
Implements baseModel< T >.
| void knnClassification< T >::setK | ( | int | newK | ) |
Change the number of nearest neighbours used by the kNN algorithm.
| new | value for k |
|
virtual |
Fill the model with a vector of examples.
| The | training set is a vector of training examples that contain both a vector of input values and a value specifying desired output class. |
Implements baseModel< T >.