IClustersType.Count

Syntax

Count: Integer;

Description

The Count property returns number of clusters.

Example

To execute the example, add a link to the Stat system assembly.

Sub UserProc;
Var
    hc: SmHierarchicalClusterAnalysis;
    Obj: ISlSeries;
    x1: Array Of Double;
    Dist: ISlDistance;
    res, i, j: Integer;
    D: Double;
    masDouble: Array Of Double;
    Cls: IClustersType;
    Cl: IClusterType;
Begin
    hc := New SmHierarchicalClusterAnalysis.Create;
    x1 := New Double[3];
    //adding characteristics, in this case, five objects with three characteristics
    x1[0] := 1; x1[1] := 1; x1[2] := 1;
    Obj := hc.Objects;
    Obj.Add.Value := x1;
    x1[0] := 2; x1[1] := 3; x1[2] := 2;
    Obj.Add.Value := x1;
    x1[0] := 3; x1[1] := 6; x1[2] := 3;
    Obj.Add.Value := x1;
    x1[0] := 4; x1[1] := 8; x1[2] := 10;
    Obj.Add.Value := x1;
    x1[0] := 5; x1[1] := 8; x1[2] := 0;
    Obj.Add.Value := x1;
    hc.ClusterLink := ClusterLinkType.Centroid;
    hc.ClusterCount := 2;
    Dist := hc.Distance;
    Dist.Type := ObjectDistanceType.EuclideanSqr;
    Dist.Standartization := StandartizationType.ScaleStd;
    res := hc.Execute;
    If res <> 0 Then
        Debug.WriteLine(hc.Errors);
    Else
        Debug.WriteLine("=== Cluster centers ===");
        Cls := hc.Clusters;
        For i := 0 To Cls.Count - 1 Do //by clusters
            Debug.Write("Cluster №" + i.ToString + " ");
            Cl := Cls.Item(i);
            masDouble := Cl.Center;
            For j := 0 To masDouble.Length-1 Do //by all attributes in cluster
                d := masDouble[j];
                Debug.Write(d.ToString + ", ");
            End For;
        Debug.WriteLine("");
        End For;
    End If;
End Sub UserProc;

After executing the example the console window displays cluster centers:

Unit execution started

=== Cluster centers===

Cluster No.0 1.5, 2, 1.5,

Cluster No.1 4, 7.33333333333333, 4.33333333333333,

Unit execution finished

See also:

IClustersType