Lloyd-style K-means clustering with configurable metric, seeding and replicates. More...
#include <kmeans.h>
Public Types | |
| typedef QSharedPointer< KMeans > | SPtr |
| typedef QSharedPointer< const KMeans > | ConstSPtr |
Public Member Functions | |
| KMeans (QString distance=QString("sqeuclidean"), QString start=QString("sample"), qint32 replicates=1, QString emptyact=QString("error"), bool online=true, qint32 maxit=100) | |
| KMeans (KMeansDistance distance, KMeansStart start=KMeansStart::Sample, qint32 replicates=1, KMeansEmptyAction emptyact=KMeansEmptyAction::Error, bool online=true, qint32 maxit=100) | |
| bool | calculate (const Eigen::MatrixXd &X, qint32 kClusters, Eigen::VectorXi &idx, Eigen::MatrixXd &C, Eigen::VectorXd &sumD, Eigen::MatrixXd &D) |
Lloyd-style K-means clustering with configurable metric, seeding and replicates.
Lloyd-style K-means partitional clustering with configurable distance metric, seeding strategy, replicate count, empty-cluster policy and optional online refinement phase.
| typedef QSharedPointer<const KMeans> UTILSLIB::KMeans::ConstSPtr |
| typedef QSharedPointer<KMeans> UTILSLIB::KMeans::SPtr |
|
explicit |
Constructs a KMeans algorithm object.
| [in] | distance | (optional) K-Means distance measure: "sqeuclidean" (default), "cityblock" , "cosine", "correlation", "hamming". |
| [in] | start | (optional) Cluster initialization: "sample" (default), "uniform", "cluster". |
| [in] | replicates | (optional) Number of K-Means replicates, which are generated. Best is returned. |
| [in] | emptyact | (optional) What happens if a cluster goes empty: "error" (default), "drop", "singleton". |
| [in] | online | (optional) If centroids should be updated during iterations: true (default), false. |
| [in] | maxit | (optional) Maximal number of iterations per replicate; 100 by default. |
Definition at line 56 of file kmeans.cpp.
|
explicit |
Constructs a KMeans algorithm object using enum parameters (preferred for performance).
| [in] | distance | Distance metric. |
| [in] | start | Cluster initialization strategy. |
| [in] | replicates | Number of K-Means replicates. Best is returned. |
| [in] | emptyact | What happens if a cluster goes empty. |
| [in] | online | If centroids should be updated during iterations. |
| [in] | maxit | Maximal number of iterations per replicate. |
Definition at line 81 of file kmeans.cpp.
| bool KMeans::calculate | ( | const Eigen::MatrixXd & | X, |
| qint32 | kClusters, | ||
| Eigen::VectorXi & | idx, | ||
| Eigen::MatrixXd & | C, | ||
| Eigen::VectorXd & | sumD, | ||
| Eigen::MatrixXd & | D ) |
Clusters input data X.
| [in] | X | Input data (rows = points; cols = p dimensional space). |
| [in] | kClusters | Number of k clusters. |
| [out] | idx | The cluster indices to which cluster the input points belong to. |
| [out] | C | Cluster centroids k x p. |
| [out] | sumD | Summation of the distances to the centroid within one cluster. |
| [out] | D | Cluster distances to the centroid. |
Definition at line 131 of file kmeans.cpp.