Class KMeansClustering performs k-means clustering on a set of data points.
Namespace:
CenterSpace.NMath.StatsAssembly: NMathStats (in NMathStats.dll) Version: 3.4.0.0
Syntax
| C# |
|---|
[SerializableAttribute] public class KMeansClustering : ICloneable |
| Visual Basic (Declaration) |
|---|
<SerializableAttribute> _ Public Class KMeansClustering _ Implements ICloneable |
| Visual C++ |
|---|
[SerializableAttribute] public ref class KMeansClustering : ICloneable |
Remarks
The k-means method assigns points into k groups such that the sum of
squares from points to the computed cluster centers is minimized.
The algorithm used by class KMeansClustering is that of Hartigan and Wong (A K-means clustering algorithm. Applied Statistics 28, 100–108. 1979). The algorithm is iterative: For each point, move it to another cluster if that would lower the energy. If you move a point, immediately update the cluster centers of the two affected clusters. Repeat until no points are moved, or the specified maximum number of iterations is reached.
Instances of class KMeansClustering are constructed from a matrix of data, where each row in the matrix represents an object to be clustered.
The algorithm used by class KMeansClustering is that of Hartigan and Wong (A K-means clustering algorithm. Applied Statistics 28, 100–108. 1979). The algorithm is iterative: For each point, move it to another cluster if that would lower the energy. If you move a point, immediately update the cluster centers of the two affected clusters. Repeat until no points are moved, or the specified maximum number of iterations is reached.
Instances of class KMeansClustering are constructed from a matrix of data, where each row in the matrix represents an object to be clustered.
Examples
// cluster 8 random vectors of length 3 DoubleMatrix data = new DoubleMatrix( 8, 3, new RandGenUniform() ); KMeansClustering cl = new KMeansClustering( data ); // create 3 clusters, using random starting cluster centers ClusterSet clusters = cl.Cluster( 3 );