K-Means clustering algorithm.
More...
#include <math/gzmath.hh>
K-Means clustering algorithm.
Given a set of observations, k-means partitions the observations into k sets so as to minimize the within-cluster sum of squares. Description based on http://en.wikipedia.org/wiki/K-means_clustering.
constructor
- Parameters
-
[in] | _obs | Set of observations to cluster. |
bool AppendObservations |
( |
const std::vector< Vector3 > & |
_obs | ) |
|
Add observations to the cluster.
- Parameters
-
[in] | _obs | Vector of observations. |
- Returns
- True if the _obs vector is not empty or false otherwise.
bool Cluster |
( |
int |
_k, |
|
|
std::vector< Vector3 > & |
_centroids, |
|
|
std::vector< unsigned int > & |
_labels |
|
) |
| |
Executes the k-means algorithm.
- Parameters
-
[in] | _k | Number of partitions to cluster. |
[out] | _centroids | Vector of centroids. Each element contains the centroid of one cluster. |
[out] | _labels | Vector of labels. The size of this vector is equals to the number of observations. Each element represents the cluster to which observation belongs. |
- Returns
- True when the operation succeed or false otherwise. The operation will fail if the number of observations is not positive, if the number of clusters is non positive, or if the number of clusters if greater than the number of observations.
std::vector<Vector3> Observations |
( |
| ) |
const |
Get the observations to cluster.
- Returns
- The vector of observations.
bool Observations |
( |
const std::vector< Vector3 > & |
_obs | ) |
|
Set the observations to cluster.
- Parameters
-
[in] | _obs | The new vector of observations. |
- Returns
- True if the vector is not empty or false otherwise.
The documentation for this class was generated from the following file: