#include <knnClassification.h>
Public Member Functions | |
knnClassification (const int &num_inputs, const std::vector< int > &which_inputs, const std::vector< trainingExample > &trainingSet, const int &k) | |
~knnClassification () | |
void | addNeighbour (const int &classNum, const std::vector< double > &features) |
double | process (const std::vector< double > &inputVector) |
void | train (const std::vector< trainingExample > &trainingSet) |
int | getNumInputs () |
std::vector< int > | getWhichInputs () |
void | getJSONDescription (Json::Value ¤tModel) |
![]() | |
virtual | ~baseModel () |
Additional Inherited Members | |
![]() | |
template<typename T > | |
Json::Value | vector2json (T vec) |
Class for implementing a knn classifier
knnClassification::knnClassification | ( | const int & | num_inputs, |
const std::vector< int > & | which_inputs, | ||
const std::vector< trainingExample > & | 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::~knnClassification | ( | ) |
void knnClassification::addNeighbour | ( | const int & | classNum, |
const std::vector< double > & | features | ||
) |
add another example to the existing training set
class | number of example |
feature | vector of example |
|
virtual |
Implements baseModel.
|
virtual |
Implements baseModel.
|
virtual |
Implements baseModel.
|
virtual |
Generate an output value from a single input vector.
A | standard vector of doubles to be evaluated. |
Implements baseModel.
|
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 double specifying desired output class. |
Implements baseModel.