42 #ifndef GRT_KNN_HEADER
43 #define GRT_KNN_HEADER
45 #include "../../CoreModules/Classifier.h"
49 #define BIG_DISTANCE 99e+99
112 virtual bool predict_(VectorDouble &inputVector);
120 virtual bool clear();
226 bool predict(
const VectorDouble &inputVector,
const UINT K);
228 double computeEuclideanDistance(
const VectorDouble &a,
const VectorDouble &b);
229 double computeCosineDistance(
const VectorDouble &a,
const VectorDouble &b);
230 double computeManhattanDistance(
const VectorDouble &a,
const VectorDouble &b);
244 enum DistanceMethods{EUCLIDEAN_DISTANCE=0,COSINE_DISTANCE,MANHATTAN_DISTANCE};
250 #endif //GRT_KNN_HEADER
UINT maxKSearchValue
The minimum K value to start the search from
virtual bool saveModelToFile(string filename) const
bool searchForBestKValue
The distance method used to compute the distance between each data point
virtual bool loadModelFromFile(string filename)
bool enableBestKValueSearch(bool searchForBestKValue)
bool setDistanceMethod(UINT distanceMethod)
static RegisterClassifierModule< KNN > registerModule
Holds the stddev of the max-class distance of the training data for each of classes ...
virtual bool train(ClassificationData trainingData)
KNN(UINT K=10, bool useScaling=false, bool useNullRejection=false, double nullRejectionCoeff=10.0, bool searchForBestKValue=false, UINT minKSearchValue=1, UINT maxKSearchValue=10)
virtual bool deepCopyFrom(const Classifier *classifier)
virtual bool train_(ClassificationData &trainingData)
bool loadLegacyModelFromFile(fstream &file)
VectorDouble trainingMu
Holds the trainingData to perform the predictions
virtual bool predict(VectorDouble inputVector)
virtual bool predict_(VectorDouble &inputVector)
bool setMaxKSearchValue(UINT maxKSearchValue)
VectorDouble trainingSigma
Holds the average max-class distance of the training data for each of classes
virtual bool recomputeNullRejectionThresholds()
bool setMinKSearchValue(UINT minKSearchValue)
virtual bool predict_(VectorDouble &inputVector)
ClassificationData trainingData
The maximum K value to end the search at
UINT minKSearchValue
Sets if the best K value should be searched for or if the model should be trained with K ...
virtual bool saveModelToFile(fstream &file) const
KNN & operator=(const KNN &rhs)
virtual bool train_(ClassificationData &trainingData)
UINT distanceMethod
The number of neighbours to search for
virtual bool loadModelFromFile(fstream &file)
bool setNullRejectionCoeff(double nullRejectionCoeff)