ComputeValues: Boolean;
The ComputeValues property determines whether the distance matrix should be calculated.
Available values:
True. Distance matrix is calculated. To get the matrix of distances between objects, use the ISlDistance.Values property.
False. Distance matrix is not calculated.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
hc: SmHierarchicalClusterAnalysis;
Obj: ISlSeries;
ClustCompOrd: IClustersCompositionOrderItem;
x1: Array[3] Of Double;
Dist: ISlDistance;
res, i, j: Integer;
D: Double;
masDouble, std: Array Of Double;
Begin
hc := New SmHierarchicalClusterAnalysis.Create;
//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;
//method of calculating distance between clusters
hc.ClusterLink := ClusterLinkType.Centroid;
//number of clusters, to which the set of objects is to be divided
hc.ClusterCount := 2;
//parameters of calculating distance between objects
Dist := hc.Distance;
//method of calculating distance between objects
Dist.Type := ObjectDistanceType.EuclideanSqr;
//method of attributes standardization
Dist.Standartization := StandartizationType.ScaleStd;
std := New Double[hc.Objects.Count];
For i := 0 To std.Length - 1 Do
std[i] := 1 + i / 2;
End For;
//standardization coefficients
Dist.StandartizationCoefficients := std;
//calculating distance matrix
hc.Distance.ComputeValues := True;
res := hc.Execute;
Debug.WriteLine(hc.Errors);
Debug.WriteLine("== Objects in the order of composition ==");
masDouble := hc.Iord;
For i := 0 To Obj.Count - 1 Do
d := masDouble[i];
Debug.WriteLine(i.ToString + " - " + d.ToString);
End For;
Debug.WriteLine("");
Debug.WriteLine("=== Clustering ===");
For i := 0 To hc.ClustersCompositionOrder.Count - 1 Do
ClustCompOrd := hc.ClustersCompositionOrder.Item(i);
Debug.Write(i.ToString + ":" + ClustCompOrd.IndexUpperCluster.ToString + "+" + ClustCompOrd.IndexLowerCluster.ToString + ",");
Debug.WriteLine(" d=" + ClustCompOrd.ClusterDistance.ToString);
End For;
Debug.WriteLine("");
Debug.WriteLine("== Distance between clusters at the moment of clustering ==");
masDouble := hc.Dord;
For i := 0 To Obj.Count - 1 Do
d := masDouble[i];
Debug.WriteLine(i.ToString + " - " + d.ToString);
End For;
Debug.WriteLine("");
Debug.WriteLine("==Distance matrix ==");
masDouble := Dist.Values;
For i := 0 To Obj.Count - 1 Do
Debug.WriteLine("Object #" + i.ToString + " ");
For j := 0 To Obj.Count - 1 Do
d := masDouble[i, j];
Debug.WriteLine(d.ToString + ", ");
End For;
End For;
End Sub UserProc;
As a result of the example execution, the following settings are defined:
Method of calculating distance between clusters.
Number of clusters, to which the set of objects is to be divided.
Method of calculating distance between objects.
Method of attributes standardization.
Settings of coefficients standardization.
The console window shows objects in the order of composition, clustering, distance between clusters at the moment of clustering and the distance matrix.
See also: