KMeansClusterAnalysis Class

Represents a K-Means cluster analysis.

Definition

Namespace: Numerics.NET.Statistics.Multivariate
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.4
C#
public class KMeansClusterAnalysis : ClusteringModel<double>
Inheritance
Object  →  Model  →  ClusteringModel<Double>  →  KMeansClusterAnalysis

Remarks

Use the KMeansClusterAnalysis class to perform a K-means cluster analysis of numerical data.

K-means clustering partitions a set of observations into a predefined number of clusters. A number of initial cluster centers is chosen. The observations are assigned to the closest cluster. Each center is then recalculated as the mean of its members. This changes the distances between cluster centers and observations, so the observations are once again reassigned. This process is repeated until no more observations change cluster. Note that the final partition depends on the initial location of the centers. Different applications may return different results for the same dataset.

The number of clusters must be passed in a constructor. It can be accessed through the NumberOfClusters property. The Standardize property determines whether the variables are transformed to all have the same mean and standard deviation. The default is true.

Once the clustering is computed by calling the Fit() method, the Centers property gives access to a vector of cluster centers. The Predictions property returns a CategoricalVector<T> that for each observation indicates the cluster it belongs to. It can be used to group the observations by their cluster assignment. GetDistancesToCenters() returns a Vector<T> that contains the distance of each observation to the center of its cluster.

Constructors

KMeansClusterAnalysis(IDataFrame, Int32) Constructs a new KMeansClusterAnalysis.
KMeansClusterAnalysis(IEnumerable<Vector<Double>>, Int32) Constructs a new KMeansClusterAnalysis.
KMeansClusterAnalysis(Matrix<Double>, Int32) Constructs a new KMeansClusterAnalysis.
KMeansClusterAnalysis(IDataFrame, String, Int32) Constructs a new KMeansClusterAnalysis.
KMeansClusterAnalysis(IDataFrame, String[], Int32) Constructs a new KMeansClusterAnalysis.

Properties

BaseFeatureIndex Gets an index containing the keys of the columns that are required inputs to the model.
(Inherited from Model)
Centers Gets an array of cluster centers.
Clusters Gets an array of clusters.
Computed Gets whether the model has been computed.
(Inherited from Model)
Obsolete.
Data Gets an object that contains all the data used as input to the model.
(Inherited from Model)
Fitted Gets whether the model has been computed.
(Inherited from Model)
InitializationMethod Gets or sets the method used to initialize the K-means algorithm.
InputSchema Gets the schema for the features used for fitting the model.
(Inherited from Model)
MaxDegreeOfParallelism Gets or sets the maximum degree of parallelism enabled by this instance.
(Inherited from Model)
ModelSchema Gets the collection of variables used in the model.
(Inherited from Model)
NumberOfClusters Gets or sets the number of clusters.
NumberOfObservations Gets the number of observations the model is based on.
(Inherited from Model)
ParallelOptions Gets or sets an object that specifies how the calculation of the model should be parallelized.
(Inherited from Model)
Predictions Returns the index of the cluster each observation belongs to as a CategoricalVector<T>.
RandomNumberGenerator Gets or sets the random number generator that may be used during the initialization of the K-means algorithm.
Standardize Gets or sets whether the variables should be standardized before the clustering is computed.
Status Gets the status of the model, which determines which information is available.
(Inherited from Model)
SupportsWeights Indicates whether the model supports case weights.
(Inherited from Model)
Weights Gets or sets the actual weights.
(Inherited from Model)

Methods

Compute() Computes the model.
(Inherited from Model)
Obsolete.
Compute(ParallelOptions) Computes the model.
(Inherited from Model)
Obsolete.
EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
Fit() Fits the model to the data.
(Inherited from Model)
Fit(ParallelOptions) Fits the model to the data.
(Inherited from Model)
FitCore Computes the clustering.
(Overrides Model.FitCore(ModelInput, ParallelOptions))
GetClusterDistances Gets a matrix that contains the distances between the clusters.
GetDavisBouldinIndex Returns the Davis-Bouldin index for the cluster analysis.
GetDistancesToCenters Returns a Vector<T> that contains the distance of each observation to its cluster center.
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
ResetComputation Clears all fitted model parameters.
(Inherited from Model)
Obsolete.
ResetFit Clears all fitted model parameters.
(Inherited from Model)
SetDataSource Uses the specified data frame as the source for all input variables.
(Inherited from Model)
Summarize() Returns a string containing a human-readable summary of the object using default options.
(Inherited from Model)
Summarize(SummaryOptions) Returns a string containing a human-readable summary of the object using the specified options.
(Overrides Model.Summarize(SummaryOptions))
ToStringReturns a string that represents the current object.
(Inherited from Model)

See Also