Files
mlpack/fastlib/branches/fastlib-old/u/example/helper.h
T
Ryan Curtin f6864dd435 Move fastlib-old (originally 'fastlib') to fastlib/branches/fastlib-old where it
will sit until the end of time and nobody will touch it because it's old
2010-01-31 22:31:55 +00:00

38 lines
727 B
C++

/**
* @file helper.h
*
* A simple K-nearest-neighbors classifier.
*/
#ifndef U_EXAMPLE_HELPER
#define U_EXAMPLE_HELPER
#include "fastlib/fastlib.h"
/**
* Simple binary K-nearest-neighbors classifier.
*/
class KnnClassifier {
private:
/** Our model *is* the data. */
Matrix matrix_;
/** Number of nearest neighbors to look at. */
int k_;
public:
/**
* Trains and initializes on a data set.
*
* Assumes that the last column is the class, and the other columns
* are just the data.
*/
void InitTrain(const Dataset& dataset, int n_classes, datanode *module);
/**
* Classifies a vector as an integer label.
*/
int Classify(const Vector& test_datum);
};
#endif