70 const std::vector<int> &
labels);
78 int predict(
const std::vector<double> &input_vector,
int k);
93 const std::vector<double> &vec2);
Represents a K Nearest Neighbors (KNN) classifier.
std::vector< std::vector< double > > training_data
int predict(const std::vector< double > &input_vector, int k)
Predicts the label of a given input vector using KNN algorithm.
std::vector< int > labels
double calculateEuclideanDistance(const std::vector< double > &vec1, const std::vector< double > &vec2)
Calculates the Euclidean distance between two vectors.
void train(const std::vector< std::vector< double >> &training_data, const std::vector< int > &labels)
Trains the KNN model with the given training data and labels.
~KNN()
Destructor for the KNN class.
KNN()
Constructor for the KNN class.
The source C++ openGPMP namespace.