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