KrisLibrary
1.0.0
|
A simple clustering method to choose k clusters from a set of data. More...
#include <KMeans.h>
Public Member Functions | |
KMeans (const std::vector< Vector > &data) | |
KMeans (const std::vector< Vector > &data, int k) | |
int | GetK () const |
void | SetK (int k) |
void | RandomInitialCenters () |
Initialization. | |
void | ClearLabels () |
void | Iterate (int &maxIters) |
Returns in maxIters the number of used iterations before convergence. | |
bool | CalcLabelsFromCenters () |
Returns true if any label has changed. | |
void | CalcCentersFromLabels () |
Sets the centers from the data points in a center's group. | |
Real | AverageDistance (int c) |
Returns the average distance of points for the given cluster. | |
void | AverageDistance (std::vector< Real > &dist) |
Same as above, but for all clusters. | |
virtual Real | Distance (const Vector &a, const Vector &b) |
Overrideable: distance metric. | |
Public Attributes | |
const std::vector< Vector > & | data |
const std::vector< Real > * | weights |
std::vector< int > | labels |
std::vector< Vector > | centers |
A simple clustering method to choose k clusters from a set of data.
The cluster centers are