Deep Learning Algorithm Implementations 1.0.0
C++ implementations of fundamental deep learning algorithms
|
#include <kmeans.hpp>
Public Member Functions | |
KMeans (size_t k, size_t max_iters=300, T tol=1e-4, int random_state=-1) | |
Constructor with number of clusters. | |
void | fit (const Matrix< T > &data) |
Fit the K-Means model to the data. | |
std::vector< int > | predict (const Matrix< T > &data) const |
Predict cluster labels for the given data. | |
std::vector< int > | fit_predict (const Matrix< T > &data) |
Fit the model and predict cluster labels. | |
Matrix< T > | cluster_centers () const |
Get the cluster centroids. | |
T | inertia () const |
Get the within-cluster sum of squares (inertia) | |
size_t | n_iter () const |
Get the number of iterations performed. | |
Definition at line 41 of file kmeans.hpp.
ml::KMeans< T >::KMeans | ( | size_t | k, |
size_t | max_iters = 300 , |
||
T | tol = 1e-4 , |
||
int | random_state = -1 |
||
) |
Constructor with number of clusters.
k | Number of clusters |
max_iters | Maximum number of iterations |
tol | Tolerance for convergence |
random_state | Random seed for reproducibility |
Definition at line 11 of file kmeans.cpp.
Matrix< T > ml::KMeans< T >::cluster_centers | ( | ) | const |
Get the cluster centroids.
Definition at line 88 of file kmeans.cpp.
void ml::KMeans< T >::fit | ( | const Matrix< T > & | data | ) |
Fit the K-Means model to the data.
data | Input data matrix where rows are samples and columns are features |
Definition at line 20 of file kmeans.cpp.
std::vector< int > ml::KMeans< T >::fit_predict | ( | const Matrix< T > & | data | ) |
Fit the model and predict cluster labels.
data | Input data matrix |
Definition at line 82 of file kmeans.cpp.
T ml::KMeans< T >::inertia | ( | ) | const |
Get the within-cluster sum of squares (inertia)
Definition at line 96 of file kmeans.cpp.
size_t ml::KMeans< T >::n_iter | ( | ) | const |
Get the number of iterations performed.
Definition at line 104 of file kmeans.cpp.
std::vector< int > ml::KMeans< T >::predict | ( | const Matrix< T > & | data | ) | const |
Predict cluster labels for the given data.
data | Input data matrix |
Definition at line 74 of file kmeans.cpp.