Settings: IBinningSettings;
Settings: Prognoz.Platform.Interop.Stat.IBinningSettings;
The Settings property returns parameters of the Binning procedure.
To get calculation results, use the ISmBinning.Categories property.
Add a link to the Stat system assembly.
Sub UserProc;
Var
Bin: SmBinning;
arr: Array Of Double;
Categories: Array Of Integer;
i, res: Integer;
Settings: IBinningSettings;
Clusters: IClustersType;
Cl: IClusterType;
Begin
// Create object to execute the Binning procedure
Bin := New SmBinning.Create;
// Set array of initial vectors
arr := New Double[14];
arr[0] := 27; arr[7] := 36;
arr[1] := 11; arr[8] := 26;
arr[2] := Double.Nan; arr[9] := 26;
arr[3] := 36; arr[10] := 9;
arr[4] := 35; arr[11] := Double.Nan;
arr[5] := Double.Nan; arr[12] := 27;
arr[6] := 11; arr[13] := 10;
Bin.Values.Value := arr;
// Get procedure settings
Settings := Bin.Settings;
// Set binning method
Settings.Method := BinningMethod.KMeansClustering;
// Set number of resulting categories
Settings.NumOfCategories := 4;
// Specify missing data as a particular category
Settings.TreatNanAsCategory := True;
// Set maximum number of iterations
Settings.MaxIt := 9;
// Execute the Binning procedure
res := Bin.Execute;
// If executing does not contain any errors, display the result to the console window
If res = 0 Then
// Display categories
Debug.WriteLine("Categories");
Categories := Bin.Categories;
Debug.Indent;
For i := 0 To Categories.Length - 1 Do
Debug.WriteLine(i.ToString + ": " + Categories[i].ToString);
End For;
Debug.Unindent;
Debug.WriteLine("");
// Display clusters
Debug.WriteLine("Clusters");
Clusters := Settings.Clusters;
Debug.Indent;
For i := 0 To Clusters.Count - 1 Do
Cl := Clusters.Item(i);
Debug.WriteLine("№ " + i.ToString);
Debug.Indent;
Debug.WriteLine(((i = 0)? "[" : "(") + Cl.LowerBound[0].ToString + ";" + Cl.UpperBound[0].ToString + "]");
Debug.WriteLine("center: " + Cl.Center[0].ToString);
Debug.WriteLine("number of objects: " + Cl.Size.ToString);
Debug.Unindent;
End For;
Debug.Unindent;
End If;
End Sub UserProc;
After executing the example the Binning procedure will be executed for the specified array. Results are displayed in console window.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Stat;
…
Public Shared Sub UserProc();
Var
Bin: SmBinning;
arr: Array Of Double;
Categories: System.Array;
i, res: Integer;
Settings: IBinningSettings;
Clusters: IClustersType;
Cl: IClusterType;
Begin
// Create object to execute the Binning procedure
Bin := New SmBinning.Create();
// Set array of initial vectors
arr := New Double[14];
arr[0] := 27; arr[7] := 36;
arr[1] := 11; arr[8] := 26;
arr[2] := Double.Nan; arr[9] := 26;
arr[3] := 36; arr[10] := 9;
arr[4] := 35; arr[11] := Double.Nan;
arr[5] := Double.Nan; arr[12] := 27;
arr[6] := 11; arr[13] := 10;
Bin.Values.Value := arr;
// Get procedure settings
Settings := Bin.Settings;
// Set binning method
Settings.Method := BinningMethod.bmKMeansClustering;
// Set number of resulting categories
Settings.NumOfCategories := 4;
// Specify missing data as a particular category
Settings.TreatNanAsCategory := True;
// Set maximum number of iterations
Settings.MaxIt := 9;
// Execute the Binning procedure
res := Bin.Execute();
// If executing does not contain any errors, display the result to the console window
If res = 0 Then
// Display categories
System.Diagnostics.Debug.WriteLine("Categories");
Categories := Bin.Categories;
System.Diagnostics.Debug.Indent();
For i := 0 To Categories.Length - 1 Do
System.Diagnostics.Debug.WriteLine(i.ToString() + ": " + Categories[i].ToString());
End For;
System.Diagnostics.Debug.Unindent();
System.Diagnostics.Debug.WriteLine("");
// Display clusters
System.Diagnostics.Debug.WriteLine("Clusters");
Clusters := Settings.Clusters;
System.Diagnostics.Debug.Indent();
For i := 0 To Clusters.Count - 1 Do
Cl := Clusters.Item[i];
System.Diagnostics.Debug.WriteLine("№ " + i.ToString());
System.Diagnostics.Debug.Indent();
System.Diagnostics.Debug.WriteLine(((i = 0)? "[" : "(") + Cl.LowerBound.GetValue(0).ToString() +
";" + Cl.UpperBound.GetValue(0).ToString() + "]");
System.Diagnostics.Debug.WriteLine("center: " + Cl.Center.GetValue(0).ToString());
System.Diagnostics.Debug.WriteLine("number of objects: " + Cl.Size.ToString());
System.Diagnostics.Debug.Unindent();
End For;
System.Diagnostics.Debug.Unindent();
End If;
End Sub UserProc;
See also: