42 #ifndef GRT_KNN_HEADER
43 #define GRT_KNN_HEADER
45 #include "../../CoreModules/Classifier.h"
49 #define BIG_DISTANCE 99e+99
65 KNN(UINT K=10,
bool useScaling=
false,
bool useNullRejection=
false,Float nullRejectionCoeff=10.0,
bool searchForBestKValue =
false,UINT minKSearchValue = 1,UINT maxKSearchValue = 10);
85 KNN &operator=(
const KNN &rhs);
120 virtual bool clear();
129 virtual bool save( std::fstream &file )
const;
138 virtual bool load( std::fstream &file );
179 bool setMinKSearchValue(UINT minKSearchValue);
187 bool setMaxKSearchValue(UINT maxKSearchValue);
196 bool enableBestKValueSearch(
bool searchForBestKValue);
214 bool setDistanceMethod(UINT distanceMethod);
226 bool loadLegacyModelFromFile( std::fstream &file );
243 enum DistanceMethods{EUCLIDEAN_DISTANCE=0,COSINE_DISTANCE,MANHATTAN_DISTANCE};
249 #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 recomputeNullRejectionThresholds()
virtual bool predict_(VectorFloat &inputVector)
bool searchForBestKValue
The distance method used to compute the distance between each data point
UINT distanceMethod
The number of neighbours to search for
ClassificationData trainingData
The maximum K value to end the search at
UINT maxKSearchValue
The minimum K value to start the search from
virtual bool save(const std::string filename) const
virtual bool load(const std::string filename)
virtual bool deepCopyFrom(const Classifier *classifier)
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 setNullRejectionCoeff(Float nullRejectionCoeff)
virtual bool train_(ClassificationData &trainingData)