IndexLowerCluster: Integer;
The IndexLowerCluster property returns number of the cluster connected with IndexUpperCluster.
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: Integer;
D: Double;
ClsOrder: IClustersCompositionOrder;
ClOrder: IClustersCompositionOrderItem;
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("Order of cluster composition");
ClsOrder := hc.ClustersCompositionOrder;
Debug.WriteLine("Lower cluster Upper cluster Distance");
For i := 0 To ClsOrder.Count - 1 Do
ClOrder := ClsOrder.Item(i);
d := ClOrder.IndexLowerCluster;
Debug.Write(d.ToString + ", ");
d := ClOrder.IndexUpperCluster;
Debug.Write(d.ToString + ", ");
d := ClOrder.ClusterDistance;
Debug.WriteLine(d.ToString);
End For;
End If;
End Sub UserProc;
After executing the example the console window displays order of cluster composition and distance between the cluster at the moment of grouping:
Unit execution started
Order of cluster composition
Lower cluster Upper cluster Distance
1, 2, 0.876065401536542
3, 5, 2.58561954166393
3, 4, 4.70500361153063
Unit execution finished
See also: