Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
K-Nearest Neighbors (Knn) class using Euclidean distance as distance metric. More...
Public Member Functions | |
Knn (std::vector< std::vector< double > > &X, std::vector< int > &Y) | |
Construct a new Knn object. | |
Knn (const Knn &model)=default | |
Knn & | operator= (const Knn &model)=default |
Knn (Knn &&)=default | |
Knn & | operator= (Knn &&)=default |
~Knn ()=default | |
Destroy the Knn object. | |
int | predict (std::vector< double > &sample, int k) |
Classify sample. | |
Private Attributes | |
std::vector< std::vector< double > > | X_ {} |
attributes vector | |
std::vector< int > | Y_ {} |
labels vector | |
K-Nearest Neighbors (Knn) class using Euclidean distance as distance metric.
|
inlineexplicit |
Construct a new Knn object.
Using lazy-learning approch, just holds in memory the dataset.
X | attributes vector |
Y | labels vector |
|
default |
Copy Constructor for class Knn.
model | instance of class to be copied |
Copy assignment operator for class Knn
Move assignment operator for class Knn
|
inline |
Classify sample.
sample | sample |
k | number of neighbors |
|
private |
attributes vector
|
private |
labels vector