K-Nearest Neighbors Classifier for classification tasks.
More...
#include <KNNClassifier.hpp>
K-Nearest Neighbors Classifier for classification tasks.
◆ KNNClassifier()
KNNClassifier::KNNClassifier |
( |
int |
k = 3 | ) |
|
|
explicit |
Constructs a KNNClassifier.
- Parameters
-
k | The number of neighbors to consider. |
◆ fit()
void KNNClassifier::fit |
( |
const std::vector< std::vector< double >> & |
X, |
|
|
const std::vector< int > & |
y |
|
) |
| |
Fits the classifier to the training data.
- Parameters
-
X | A vector of feature vectors (training data). |
y | A vector of target class labels (training labels). |
◆ predict()
std::vector< int > KNNClassifier::predict |
( |
const std::vector< std::vector< double >> & |
X | ) |
const |
Predicts class labels for the given input data.
- Parameters
-
X | A vector of feature vectors (test data). |
- Returns
- A vector of predicted class labels.
The documentation for this class was generated from the following file: