Click or drag to resize

ClusterAnalysis Class

Class ClusterAnalysis perform hierarchical cluster analysis.
Inheritance Hierarchy
SystemObject
  CenterSpace.NMath.CoreClusterAnalysis

Namespace:  CenterSpace.NMath.Core
Assembly:  NMath (in NMath.dll) Version: 7.3
Syntax
public class ClusterAnalysis : ICloneable

The ClusterAnalysis type exposes the following members.

Constructors
  NameDescription
Public methodClusterAnalysis
Default constructor. Constructs an empty ClusterAnalysis instance.
Public methodClusterAnalysis(DataFrame)
Default constructor. Constructs a ClusterAnalysis instance from the given data, using the current default distance and linkage delegates.
Public methodClusterAnalysis(DoubleMatrix)
Constructs a ClusterAnalysis instance from the given data, using the current default distance and linkage delegates.
Public methodClusterAnalysis(DataFrame, DistanceFunction)
Constructs a ClusterAnalysis instance from the given data, using the given distance delegates.
Public methodClusterAnalysis(DataFrame, LinkageFunction)
Constructs a ClusterAnalysis instance from the given data, using the given distance delegates.
Public methodClusterAnalysis(DoubleMatrix, DistanceFunction)
Constructs a ClusterAnalysis instance from the given data, using the given distance delegates.
Public methodClusterAnalysis(DoubleMatrix, LinkageFunction)
Constructs a ClusterAnalysis instance from the given data, using the given distance delegates.
Public methodClusterAnalysis(DataFrame, DistanceFunction, LinkageFunction)
Constructs a ClusterAnalysis instance from the given data, using the given distance and linkage delegates.
Public methodClusterAnalysis(DoubleMatrix, DistanceFunction, LinkageFunction)
Constructs a ClusterAnalysis instance from the given data, using the given distance and linkage delegates.
Top
Properties
  NameDescription
Public propertyCopheneticDistances
Gets the vector of cophenetic distances between all possible object pairs.
Public propertyStatic memberDefaultDistanceFunction
Gets and sets the default distance delegate associated with ClusterAnalysis objects.
Public propertyStatic memberDefaultLinkageFunction
Gets and sets the default linkage delegate associated with ClusterAnalysis objects.
Public propertyDistanceFunction
Gets and sets the distance measurement delegate used by this ClusterAnalysis instance to determine the distance between individual objects.
Public propertyDistances
Gets the vector of distances between all possible object pairs, computed using the current distance delegate.
Public propertyLinkageFunction
Gets and sets the linkage measurement delegate used by this ClusterAnalysis instance to determine the distance between clusters.
Public propertyLinkages
Gets the complete hierarchical linkage tree, computed from Distances using the current linkage delegate.
Public propertyN
Gets the total number of objects.
Top
Methods
  NameDescription
Public methodClone
Creates a deep copy of this cluster analysis.
Public methodCutTree(Double)
Constructs a set of clusters by cutting the hierarchical linkage tree at the specified height.
Public methodCutTree(Int32)
Constructs the specified number of clusters from the hierarchical linkage tree.
Protected methodGetDistances
Computes the vector of distances between all possible object pairs, using the current distance delegate.
Protected methodGetLinkages
Computes the complete hierarchical linkage tree, using the current distance vector and linkage delegate.
Public methodUpdate(DataFrame)
Clusters the given data, using the current Distance and Linkage delegates.
Public methodUpdate(DoubleMatrix)
Clusters the given data, using the current Distance and Linkage delegates.
Public methodUpdate(DataFrame, DistanceFunction)
Clusters the given data, using the given distance delegate and the current linkage delegate.
Public methodUpdate(DataFrame, LinkageFunction)
Clusters the given data, using the current distance delegate and the given linkage delegate.
Public methodUpdate(DoubleMatrix, DistanceFunction)
Clusters the given data, using the given distance delegate and the current linkage delegate.
Public methodUpdate(DoubleMatrix, LinkageFunction)
Clusters the given data, using the current distance delegate and the given linkage delegate.
Public methodUpdate(DataFrame, DistanceFunction, LinkageFunction)
Clusters the given data, using the given distance and linkage delegates.
Public methodUpdate(DoubleMatrix, DistanceFunction, LinkageFunction)
Clusters the given data, using the given distance and linkage delegates.
Top
Fields
  NameDescription
Protected fieldcophenetic_
The cophenetic distances. Calculated on-demand and cached.
Protected fielddistanceFunction_
Distance metric delegate.
Protected fielddistances_
The distances between all object pairs.
Protected fieldlinkageFunction_
Linkage metric delegate.
Protected fieldlinkages_
The complete heirarchical linkage tree.
Protected fieldn_
The total number of objects.
Top
Remarks
Instances of class ClusterAnalysis are constructed from a matrix of data, where each row in the matrix represents an object to be clustered. Initially, each object is assigned to its own singleton cluster and then the analysis proceeds iteratively, at each stage joining the two most similar clusters into a new cluster, continuing until there is one overall cluster.
Distances between objects are computed using a Distance.Function delegate. Delegates are provided as static variables on class Distance for euclidean, squared euclidean, city-block (Manhattan), maximum (Chebychev), and power distance functions. You can also create your own distance function delegate. Property Distances gets the vector of distances between all possible object pairs, computed using the current distance delegate.
Distances between clusters of objects are computed using a Linkage.Function delegate. Delegates are provided as static variables on class Linkage for single, complete, unweighted average, weighted average, centroid, median, and Ward's linkage functions. Again, you can also create your own linkage function delegate. The Linkages property gets the complete hierarchical linkage tree, computed from Distances using the current linkage delegate.
The CutTree() method constructs a set of clusters by cutting the hierarchical linkage tree either at the specified height, or into the specified number of clusters.
Examples
// cluster 8 random vectors of length 3
DoubleMatrix data = new DoubleMatrix( 8, 3, new RandGenUniform() );
ClusterAnalysis ca = new ClusterAnalysis( data,
  Distance.SquaredEuclideanFunction, Linkage.CompleteFunction );
Console.WriteLine( ca.Distances );
Console.WriteLine( ca.Linkages );

// cut linkage tree to form 3 clusters
Console.WriteLine( ca.CutTree( 3 ) );

// cut linkage tree at height of 0.75
Console.WriteLine( ca.CutTree( 0.75 ) );
See Also