Implementation of the k-means algorithm.
More...
#include <KMeans.hpp>
Implementation of the k-means algorithm.
- Author
- Douglas De Rizzo Meneghetti (dougl.nosp@m.asri.nosp@m.zzom@.nosp@m.gmai.nosp@m.l.com)
- Date
- 2017-10-25 Implementaion of the k-means algorithm
Definition at line 17 of file KMeans.hpp.
◆ InitializationMethod
◆ KMeans()
◆ fit()
void KMeans::fit |
( |
MatrixD |
data, |
|
|
unsigned int |
k, |
|
|
unsigned int |
iters = 100 , |
|
|
unsigned int |
inits = 100 , |
|
|
double |
distance = 2 , |
|
|
InitializationMethod |
initMethod = SAMPLE , |
|
|
bool |
verbose = false |
|
) |
| |
|
inline |
Find the k centroids that best fit the data.
- Parameters
-
data | a Matrix containing the data |
k | number of clusters to be generated |
iters | number of maximum assignment/adjustment iterations |
inits | number of algorithm reinitialization |
distance | L norm of the distance measure to be used (1 for Manhattan, 2 for Euclidean etc.) |
initMethod | centroid initialization method |
verbose | whether to output progress or not |
Definition at line 72 of file KMeans.hpp.
◆ getCentroids()
const MatrixD& KMeans::getCentroids |
( |
| ) |
const |
|
inline |
◆ getDistance()
double KMeans::getDistance |
( |
| ) |
const |
|
inline |
◆ getK()
unsigned int KMeans::getK |
( |
| ) |
const |
|
inline |
◆ getSse()
double KMeans::getSse |
( |
| ) |
const |
|
inline |
◆ getTotalIterations()
unsigned int KMeans::getTotalIterations |
( |
| ) |
const |
|
inline |
◆ getY()
const MatrixD& KMeans::getY |
( |
| ) |
const |
|
inline |
◆ predict()
MatrixD KMeans::predict |
( |
MatrixD |
data | ) |
|
|
inline |
Assigns elements of a data set to clusters.
- Parameters
-
data | a Matrix containing elements in rows and features in columns |
- Returns
- column vector with the index of clusters each element is assigned to
Definition at line 41 of file KMeans.hpp.
◆ SSE()
- Returns
- Sum of squared errors between elements and their centroids
Definition at line 29 of file KMeans.hpp.
◆ centroids
MatrixD KMeans::centroids |
|
private |
◆ distance
◆ initMethod
◆ sse
◆ totalIterations
unsigned int KMeans::totalIterations |
|
private |
The documentation for this class was generated from the following file: