26 #ifndef GRT_KNN_HEADER 27 #define GRT_KNN_HEADER 29 #include "../../CoreModules/Classifier.h" 33 #define BIG_DISTANCE 99e+99 54 enum DistanceMethods{EUCLIDEAN_DISTANCE=0,COSINE_DISTANCE,MANHATTAN_DISTANCE};
67 KNN(UINT K=10,
bool useScaling=
false,
bool useNullRejection=
false,Float nullRejectionCoeff=10.0,
bool searchForBestKValue =
false,UINT minKSearchValue = 1,UINT maxKSearchValue = 10);
87 KNN &operator=(
const KNN &rhs);
122 virtual bool clear();
131 virtual bool save( std::fstream &file )
const;
140 virtual bool load( std::fstream &file );
181 bool setMinKSearchValue(UINT minKSearchValue);
189 bool setMaxKSearchValue(UINT maxKSearchValue);
198 bool enableBestKValueSearch(
bool searchForBestKValue);
216 bool setDistanceMethod(UINT distanceMethod);
223 static std::string
getId();
235 bool loadLegacyModelFromFile( std::fstream &file );
251 static const std::string id;
256 #endif //GRT_KNN_HEADER VectorFloat trainingSigma
Holds the average max-class distance of the training data for each of classes
std::string getId() const
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
virtual bool setNullRejectionCoeff(const Float nullRejectionCoeff)
UINT distanceMethod
The number of neighbours to search for
ClassificationData trainingData
The maximum K value to end the search at
virtual bool save(const std::string &filename) const
UINT maxKSearchValue
The minimum K value to start the search from
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 ...
VectorFloat trainingMu
Holds the trainingData to perform the predictions
virtual bool train_(ClassificationData &trainingData)
virtual bool load(const std::string &filename)
This is the main base class that all GRT Classification algorithms should inherit from...