ClassificationSummary: Array;
ClassificationSummary: System.Array;
The ClassificationSummary property returns summary results of classification.
To get a list of categories, use the ISmGradientBoostedTree.CategoriesListproperty.
Add a link to the Stat system assembly.
Sub UserProc;
Var
GB: SmGradientBoostedTree;
y: Array[20] Of Double;
x1ord: Array[20] Of integer;
x2ord: Array[20] Of integer;
x3dbl: array[20] Of double;
x4cat: array[20] Of integer;
TreeSizeSpecification: ITreeSpecification;
BinningSett: IBinningSettingsInt;
ExpSeries: ISlSeriesInt;
ESeries: ISlSerieInt;
Series: ISlSeries;
Serie: ISlSerie;
CrossValidation: ICrossValidation;
i, j, res: integer;
str: String;
d: double;
CrossValPerf: ICrossValidationPerformanceScores;
TreeNode: IBinaryTreeNode;
CatList, BinningRes, CategoriesList: Array Of Integer;
PerformanceMatrix, OneMinusSpecificity, Sensitivity, CutOffPoints: Array Of Double;
ROCcurve: IROCcurve;
Begin
// Create object for gradient boosting calculation
GB := New SmGradientBoostedTree.Create;
// Set explained series values
y[0] := 0; y[5] := 1; y[10] := 1; y[15] := 1;
y[1] := 1; y[6] := 0; y[11] := 1; y[16] := 0;
y[2] := 0; y[7] := 1; y[12] := 1; y[17] := 1;
y[3] := 0; y[8] := 0; y[13] := 0; y[18] := 0;
y[4] := 0; y[9] := 0; y[14] := 0; y[19] := 1;
// Set values of the Ord1 explanatory ordinal series
x1ord[0] := 0; x1ord[5] := 0; x1ord[10] := 1; x1ord[15] := 1;
x1ord[1] := 0; x1ord[6] := 0; x1ord[11] := 1; x1ord[16] := -1;
x1ord[2] := 0; x1ord[7] := 0; x1ord[12] := 1; x1ord[17] := 0;
x1ord[3] := 0; x1ord[8] := 0; x1ord[13] := 1; x1ord[18] := 0;
x1ord[4] := 0; x1ord[9] := 1; x1ord[14] := 1; x1ord[19] := 1;
// Set values of the Ord2 explanatory ordinal series
x2ord[0] := 10; x2ord[5] := 20; x2ord[10] := 10; x2ord[15] := -1;
x2ord[1] := 10; x2ord[6] := 20; x2ord[11] := 20; x2ord[16] := 20;
x2ord[2] := 10; x2ord[7] := 20; x2ord[12] := 20; x2ord[17] := 20;
x2ord[3] := 10; x2ord[8] := 20; x2ord[13] := 20; x2ord[18] := 20;
x2ord[4] := 10; x2ord[9] := 10; x2ord[14] := 20; x2ord[19] := 10;
// Set values of explanatory quantitative series
x3dbl[0] := 1; x3dbl[5] := 6; x3dbl[10] := 10; x3dbl[15] := 14;
x3dbl[1] := 2; x3dbl[6] := 7; x3dbl[11] := 10; x3dbl[16] := 4;
x3dbl[2] := 3; x3dbl[7] := 8; x3dbl[12] := 11; x3dbl[17] := 8;
x3dbl[3] := 5; x3dbl[8] := 9; x3dbl[13] := 12; x3dbl[18] := 9;
x3dbl[4] := 4; x3dbl[9] := 9; x3dbl[14] := 13; x3dbl[19] := 9;
// Set values of explanatory categorical series
x4cat[0] := 21; x4cat[5] := 21; x4cat[10] := 12; x4cat[15] := 13;
x4cat[1] := 21; x4cat[6] := 21; x4cat[11] := 12; x4cat[16] := 13;
x4cat[2] := 21; x4cat[7] := 12; x4cat[12] := 13; x4cat[17] := 13;
x4cat[3] := 21; x4cat[8] := 12; x4cat[13] := 13; x4cat[18] := 13;
x4cat[4] := 21; x4cat[9] := 12; x4cat[14] := 13; x4cat[19] := 12;
// Set number of iterations
GB.NumberOfIterations := 5;
// Set training speed coefficient
GB.LearningRate := 0.15;
// Set tree description parameters
TreeSizeSpecification := GB.TreeSizeSpecification;
TreeSizeSpecification.MaximumNumberOfLevels := 1;
TreeSizeSpecification.MinimumNumberOfCases := 2;
// Set an explained series and set up the Binning procedure for it
GB.Dependent.Name:="Explained";
BinningSett := GB.Dependent.BinningSettings;
BinningSett.DoubleValue := y;
BinningSett.Method := binningmethod.EqualDepth;
BinningSett.NumOfCategories := 3;
// Set explanatory ordinal series
ExpSeries := GB.ExplanatoriesOrdered;
// Series Ord1
ESeries := ExpSeries.Add;
ESeries.Value := x1ord;
ESeries.Name := "Ord1";
// Series Ord2
ESeries := ExpSeries.Add;
ESeries.Value := x2ord;
ESeries.Name := "Ord2";
// Set explanatory quantitative series
Series := GB.ExplanatoriesContinuous;
Serie := Series.Add;
Serie.Value := x3dbl;
Serie.Name := "x3dbl";
// Set explanatory categorical series
ExpSeries := GB.ExplanatoriesCategorical;
ESeries := ExpSeries.Add;
ESeries.Value := x4cat;
ESeries.Name := "Cat1";
// Set cross-validation parameters
CrossValidation := GB.CrossValidation;
CrossValidation.SamplingType := CrossValidationSamplingType.RandomSampling;
CrossValidation.NumberOfRandomTests := 15;
CrossValidation.TrainingSetSize := 60;
// Set ROC curve parameters
ROCcurve := GB.ROCcurve;
ROCcurve.ConfidenceLevel := 0.85;
// Perform calculation
res := GB.Execute;
// Output calculation results
If res <> 0 Then
Debug.WriteLine("Error occurred:");
Debug.WriteLine(GB.Errors);
Else
// Output initial and processed values
Debug.WriteLine("Initial values; Processed values;");
Debug.Indent;
For i := 0 To BinningSett.DoubleValue.Length - 1 Do
str := i.ToString + ": ";
d := BinningSett.DoubleValue[i];
str := str + d.ToString + " - ";
d := GB.FilledDependent[i];
str := str + d.ToString + " ";
Debug.WriteLine(str);
End For;
Debug.Unindent;
// Output posterior probabilities
Debug.WriteLine("A posteriori probabilities:");
Debug.Indent;
For i := 0 To GB.PseudoProbability.GetUpperBound(1) Do
str := i.ToString + ": ";
For j := 0 To GB.PseudoProbability.GetUpperBound(2) Do
d := GB.PseudoProbability[i, j];
str := str + d.ToString + ", ";
End For;
Debug.WriteLine(str);
End For;
Debug.Unindent;
// Display list of categories
CatList := GB.CategoriesList;
If CatList.Length > 0 Then
Debug.WriteLine("List of categories:");
Debug.Indent;
For i := 0 To CatList.Length - 1 Do
Debug.WriteLine(CatList[i]);
End For;
Debug.Unindent;
End If;
// Output summary classification results
Debug.WriteLine("Summary classification results:");
Debug.Indent;
str := "";
For i := 0 To GB.ClassificationSummary.GetUpperBound(1) Do
For j := 0 To GB.ClassificationSummary.GetUpperBound(2) Do
str := str + GB.ClassificationSummary[i, j].ToString + " ";
End For;
Debug.WriteLine(str);
str := "";
End For;
Debug.Unindent;
// Output Binning procedure calculation results
Debug.WriteLine("Binning procedure calculation results:");
Debug.Indent;
BinningRes := BinningSett.IntegerValue;
For i := 0 To BinningRes.Length - 1 Do
Debug.WriteLine(BinningRes[i]);
End For;
Debug.Unindent;
// Output cross-validation results
GB.ExecuteValidation;
CrossValPerf := GB.PerformanceScores;
Debug.WriteLine("Cross-validation results:");
Debug.Indent;
Debug.WriteLine("Analyzed attribute: " + CrossValPerf.ClassificatorName);
Debug.Write("Number of factors affecting the analyzed attribute: ");
Debug.WriteLine(CrossValPerf.FactorsNumber);
Debug.WriteLine("Number of observations: " + CrossValPerf.ObservationsNumber.ToString);
Debug.WriteLine("Number of repetitions: " + CrossValidation.NumberOfRandomTests.ToString);
Debug.WriteLine("Classification accuracy: " + CrossValPerf.ClassificationAccuracy.ToString);
Debug.WriteLine("Categories:");
Debug.Indent;
CategoriesList := CrossValPerf.CategoriesList;
For i := 0 To CategoriesList.Length - 1 Do
Debug.WriteLine(CategoriesList[i]);
End For;
Debug.Unindent;
Debug.WriteLine("Correct classification:");
Debug.Indent;
PerformanceMatrix := CrossValPerf.PerformanceMatrix;
For i := 0 To PerformanceMatrix.GetUpperBound(1) Do
For j := 0 To PerformanceMatrix.GetUpperBound(2) Do
Debug.Write(PerformanceMatrix[i, j].ToString + #9);
End For;
Debug.WriteLine("");
End For;
Debug.Unindent;
Debug.Unindent;
// Output ROC curve data
Debug.WriteLine("ROC curve data:");
Debug.Indent;
Debug.WriteLine("Specificity:");
Debug.Indent;
OneMinusSpecificity := ROCcurve.OneMinusSpecificity;
For i := 0 To OneMinusSpecificity.Length - 1 Do
Debug.WriteLine(OneMinusSpecificity[i]);
End For;
Debug.Unindent;
Debug.WriteLine("Sensitivity:");
Debug.Indent;
Sensitivity := ROCcurve.Sensitivity;
For i := 0 To Sensitivity.Length - 1 Do
Debug.WriteLine(Sensitivity[i]);
End For;
Debug.Unindent;
Debug.WriteLine("Area under curve: " + ROCcurve.Area.ToString);
Debug.WriteLine("Standard error: " + ROCcurve.StdError.ToString);
Debug.WriteLine("Asymptotic confidence interval:");
Debug.Indent;
Debug.WriteLine("Lower limit: " + ROCcurve.ConfidenceIntervalLower.ToString);
Debug.WriteLine("Upper limit: " + ROCcurve.ConfidenceIntervalUpper.ToString);
Debug.Unindent;
Debug.WriteLine("Cutoff threshold:");
Debug.Indent;
CutOffPoints := ROCcurve.CutOffPoints;
For i := 0 To CutOffPoints.Length - 1 Do
Debug.WriteLine(CutOffPoints[i]);
End For;
Debug.Unindent;
Debug.Unindent;
// Output decision tree
For i := 0 To GB.Trees.Count1 - 1 Do
For j := 0 To GB.Trees.Count2 - 1 Do
TreeNode := GB.Trees.Item(i, j);
If TreeNode <> Null Then
Debug.Write("Decision tree");
Debug.WriteLine(" [" + i.ToString + "," + j.ToString + "]:");
print(TreeNode);
Debug.WriteLine("");
End If;
End For;
End For;
End If;
End Sub UserProc;
// Decision tree output procedure
Sub print(node: IBinaryTreeNode);
Var
i: Integer;
Categorical: Boolean = False;
Begin
Debug.Indent;
Debug.WriteLine("Node No.: " + node.NodeIndex.ToString);
Debug.WriteLine("Number of node cases: " + node.Total.ToString);
Debug.WriteLine("Criterion index: " + node.ExplanatorieIndex.ToString);
Debug.WriteLine("Criterion name: " + node.Name);
Debug.Write("Criterion type: ");
Select Case node.PropertyType
Case
DecisionTreePropertyType.Categorical: Debug.WriteLine("categorical");
Categorical := True;
Case DecisionTreePropertyType.NoProperty: Debug.WriteLine("-");
Case DecisionTreePropertyType.Ordered: Debug.WriteLine("ordinal");
Case DecisionTreePropertyType.Value: Debug.WriteLine("quantitative");
End Select;
If Not Categorical Then
Debug.WriteLine("Criterion value: " + node.Value.ToString);
End If;
Debug.WriteLine("Variance: " + node.Disp.ToString);
Debug.WriteLine("Mean: " + node.Mean.ToString);
Debug.WriteLine("Sum of squared residuals: " + node.SSR.ToString);
If (node.LeftNode <> Null) Then
Debug.WriteLine("Left branch: ");
print(node.LeftNode);
End If;
If (node.LeftNodeCategories.Length <> 0) And Categorical Then
Debug.WriteLine("List of categories that are sent to the left branch: ");
For i := 0 To node.LeftNodeCategories.Length - 1 Do
Debug.WriteLine(node.LeftNodeCategories[i]);
End For;
End If;
If (node.RightNode <> Null) Then
Debug.WriteLine("Right branch: ");
print(node.RightNode);
End If;
If (node.RightNodeCategories.Length <> 0) And Categorical Then
Debug.WriteLine("List of categories that are sent to the right branch: ");
For i := 0 To node.RightNodeCategories.Length - 1 Do
Debug.WriteLine(node.RightNodeCategories[i]);
End For;
End If;
Debug.Unindent;
End Sub print;
After executing the example, the task will be calculated using gradient boosting method. Calculation results are displayed to the browser console.
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 Main(Params: StartParams);
Var
GB: SmGradientBoostedTree;
y: Array[20] Of Double;
x1ord: Array[20] Of integer;
x2ord: Array[20] Of integer;
x3dbl: array[20] Of double;
x4cat: array[20] Of integer;
TreeSizeSpecification: ITreeSpecification;
BinningSett: IBinningSettingsInt;
ExpSeries: ISlSeriesInt;
ESeries: ISlSerieInt;
Series: ISlSeries;
Serie: ISlSerie;
CrossValidation: ICrossValidation;
i, j, res: integer;
str: String;
d: double;
CrossValPerf: ICrossValidationPerformanceScores;
TreeNode: IBinaryTreeNode;
CatList, BinningRes, CategoriesList: System.Array;
PerformanceMatrix, OneMinusSpecificity, Sensitivity, CutOffPoints: System.Array;
ROCcurve: IROCcurve;
Begin
// Create object for gradient boosting calculation
GB := New SmGradientBoostedTree.Create();
// Set explained series values
y[0] := 0; y[5] := 1; y[10] := 1; y[15] := 1;
y[1] := 1; y[6] := 0; y[11] := 1; y[16] := 0;
y[2] := 0; y[7] := 1; y[12] := 1; y[17] := 1;
y[3] := 0; y[8] := 0; y[13] := 0; y[18] := 0;
y[4] := 0; y[9] := 0; y[14] := 0; y[19] := 1;
// Set values of the Ord1 explanatory ordinal series
x1ord[0] := 0; x1ord[5] := 0; x1ord[10] := 1; x1ord[15] := 1;
x1ord[1] := 0; x1ord[6] := 0; x1ord[11] := 1; x1ord[16] := -1;
x1ord[2] := 0; x1ord[7] := 0; x1ord[12] := 1; x1ord[17] := 0;
x1ord[3] := 0; x1ord[8] := 0; x1ord[13] := 1; x1ord[18] := 0;
x1ord[4] := 0; x1ord[9] := 1; x1ord[14] := 1; x1ord[19] := 1;
// Set values of the Ord2 explanatory ordinal series
x2ord[0] := 10; x2ord[5] := 20; x2ord[10] := 10; x2ord[15] := -1;
x2ord[1] := 10; x2ord[6] := 20; x2ord[11] := 20; x2ord[16] := 20;
x2ord[2] := 10; x2ord[7] := 20; x2ord[12] := 20; x2ord[17] := 20;
x2ord[3] := 10; x2ord[8] := 20; x2ord[13] := 20; x2ord[18] := 20;
x2ord[4] := 10; x2ord[9] := 10; x2ord[14] := 20; x2ord[19] := 10;
// Set values of explanatory quantitative series
x3dbl[0] := 1; x3dbl[5] := 6; x3dbl[10] := 10; x3dbl[15] := 14;
x3dbl[1] := 2; x3dbl[6] := 7; x3dbl[11] := 10; x3dbl[16] := 4;
x3dbl[2] := 3; x3dbl[7] := 8; x3dbl[12] := 11; x3dbl[17] := 8;
x3dbl[3] := 5; x3dbl[8] := 9; x3dbl[13] := 12; x3dbl[18] := 9;
x3dbl[4] := 4; x3dbl[9] := 9; x3dbl[14] := 13; x3dbl[19] := 9;
// Set values of explanatory categorical series
x4cat[0] := 21; x4cat[5] := 21; x4cat[10] := 12; x4cat[15] := 13;
x4cat[1] := 21; x4cat[6] := 21; x4cat[11] := 12; x4cat[16] := 13;
x4cat[2] := 21; x4cat[7] := 12; x4cat[12] := 13; x4cat[17] := 13;
x4cat[3] := 21; x4cat[8] := 12; x4cat[13] := 13; x4cat[18] := 13;
x4cat[4] := 21; x4cat[9] := 12; x4cat[14] := 13; x4cat[19] := 12;
// Set number of iterations
GB.NumberOfIterations := 5;
// Set training speed coefficient
GB.LearningRate := 0.15;
// Set tree description parameters
TreeSizeSpecification := GB.TreeSizeSpecification;
TreeSizeSpecification.MaximumNumberOfLevels := 1;
TreeSizeSpecification.MinimumNumberOfCases := 2;
// Set explained series and set up the Binning procedure for it
GB.Dependent.Name:="Explained";
BinningSett := GB.Dependent.BinningSettings;
BinningSett.DoubleValue := y;
BinningSett.Method := binningmethod.bmEqualDepth;
BinningSett.NumOfCategories := 3;
// Set explanatory ordinal series
ExpSeries := GB.ExplanatoriesOrdered;
// Series Ord1
ESeries := ExpSeries.Add();
ESeries.Value := x1ord;
ESeries.Name := "Ord1";
// Series Ord2
ESeries := ExpSeries.Add();
ESeries.Value := x2ord;
ESeries.Name := "Ord2";
// Set explanatory quantitative series
Series := GB.ExplanatoriesContinuous;
Serie := Series.Add();
Serie.Value := x3dbl;
Serie.Name := "x3dbl";
// Set explanatory categorical series
ExpSeries := GB.ExplanatoriesCategorical;
ESeries := ExpSeries.Add();
ESeries.Value := x4cat;
ESeries.Name := "Cat1";
// Set cross-validation parameters
CrossValidation := GB.CrossValidation;
CrossValidation.SamplingType := CrossValidationSamplingType.cvstRandomSampling;
CrossValidation.NumberOfRandomTests := 15;
CrossValidation.TrainingSetSize := 60;
// Set ROC curve parameters
ROCcurve := GB.ROCcurve;
ROCcurve.ConfidenceLevel := 0.85;
// Perform calculation
res := GB.Execute();
// Output calculation results
If res <> 0 Then
System.Diagnostics.Debug.WriteLine("Error occurred:");
System.Diagnostics.Debug.WriteLine(GB.Errors);
Else
// Output initial and processed values
System.Diagnostics.Debug.WriteLine("Initial values; Processed values;");
System.Diagnostics.Debug.Indent();
For i := 0 To BinningSett.DoubleValue.Length - 1 Do
str := i.ToString() + ": ";
str := str + BinningSett.DoubleValue.GetValue(i).ToString() + " - ";
str := str + BinningSett.DoubleValue.GetValue(i).ToString() + " ";
System.Diagnostics.Debug.WriteLine(str);
End For;
System.Diagnostics.Debug.Unindent();
// Output posterior probabilities
System.Diagnostics.Debug.WriteLine("A posteriori probabilities:");
System.Diagnostics.Debug.Indent();
For i := 0 To GB.PseudoProbability.GetUpperBound(0) Do
str := i.ToString() + ": ";
For j := 0 To GB.PseudoProbability.GetUpperBound(1) Do
d := GB.PseudoProbability.GetValue(i, j) As double;
str := str + d.ToString() + ", ";
End For;
System.Diagnostics.Debug.WriteLine(str);
End For;
System.Diagnostics.Debug.Unindent();
// Display list of categories
CatList := GB.CategoriesList;
If CatList.Length > 0 Then
System.Diagnostics.Debug.WriteLine("List of categories:");
System.Diagnostics.Debug.Indent();
For i := 0 To CatList.Length - 1 Do
System.Diagnostics.Debug.WriteLine(CatList[i]);
End For;
System.Diagnostics.Debug.Unindent();
End If;
// Display summary classification results
System.Diagnostics.Debug.WriteLine("Summary classification results:");
System.Diagnostics.Debug.Indent();
str := "";
For i := 0 To GB.ClassificationSummary.GetUpperBound(0) Do
For j := 0 To GB.ClassificationSummary.GetUpperBound(1) Do
str := str + GB.ClassificationSummary.GetValue(i, j).ToString() + " ";
End For;
System.Diagnostics.Debug.WriteLine(str);
str := "";
End For;
System.Diagnostics.Debug.Unindent();
// Output Binning procedure calculation results
System.Diagnostics.Debug.WriteLine("Binning procedure calculation results:");
System.Diagnostics.Debug.Indent();
BinningRes := BinningSett.IntegerValue;
For i := 0 To BinningRes.Length - 1 Do
System.Diagnostics.Debug.WriteLine(BinningRes[i]);
End For;
System.Diagnostics.Debug.Unindent();
// Output cross-validation results
GB.ExecuteValidation();
CrossValPerf := GB.PerformanceScores;
System.Diagnostics.Debug.WriteLine("Cross-validation results:");
System.Diagnostics.Debug.Indent();
System.Diagnostics.Debug.WriteLine("Analyzed attribute: " + CrossValPerf.ClassificatorName);
System.Diagnostics.Debug.Write("Number of factors affecting the analyzed attribute: ");
System.Diagnostics.Debug.WriteLine(CrossValPerf.FactorsNumber);
System.Diagnostics.Debug.WriteLine("Number of observations: " + CrossValPerf.ObservationsNumber.ToString());
System.Diagnostics.Debug.WriteLine("Number of repetitions: " + CrossValidation.NumberOfRandomTests.ToString());
System.Diagnostics.Debug.WriteLine("Classification accuracy: " + CrossValPerf.ClassificationAccuracy.ToString());
System.Diagnostics.Debug.WriteLine("Categories:");
System.Diagnostics.Debug.Indent();
CategoriesList := CrossValPerf.CategoriesList;
For i := 0 To CategoriesList.Length - 1 Do
System.Diagnostics.Debug.WriteLine(CategoriesList[i]);
End For;
System.Diagnostics.Debug.Unindent();
System.Diagnostics.Debug.WriteLine("Correct classification:");
System.Diagnostics.Debug.Indent();
PerformanceMatrix := CrossValPerf.PerformanceMatrix;
For i := 0 To PerformanceMatrix.GetUpperBound(1) Do
For j := 0 To PerformanceMatrix.GetUpperBound(0) Do
System.Diagnostics.Debug.Write(PerformanceMatrix[j, i].ToString() + char.ConvertFromUtf32(9));
End For;
System.Diagnostics.Debug.WriteLine("");
End For;
System.Diagnostics.Debug.Unindent();
System.Diagnostics.Debug.Unindent();
// Output ROC curve data
System.Diagnostics.Debug.WriteLine("ROC curve data:");
System.Diagnostics.Debug.Indent();
System.Diagnostics.Debug.WriteLine("Specificity:");
System.Diagnostics.Debug.Indent();
OneMinusSpecificity := ROCcurve.OneMinusSpecificity;
For i := 0 To OneMinusSpecificity.Length - 1 Do
System.Diagnostics.Debug.WriteLine(OneMinusSpecificity[i]);
End For;
System.Diagnostics.Debug.Unindent();
System.Diagnostics.Debug.WriteLine("Sensitivity:");
System.Diagnostics.Debug.Indent();
Sensitivity := ROCcurve.Sensitivity;
For i := 0 To Sensitivity.Length - 1 Do
System.Diagnostics.Debug.WriteLine(Sensitivity[i]);
End For;
System.Diagnostics.Debug.Unindent();
System.Diagnostics.Debug.WriteLine("Area under curve: " + ROCcurve.Area.ToString());
System.Diagnostics.Debug.WriteLine("Standard error: " + ROCcurve.StdError.ToString());
System.Diagnostics.Debug.WriteLine("Asymptotic confidence interval:");
System.Diagnostics.Debug.Indent();
System.Diagnostics.Debug.WriteLine("Lower limit: " + ROCcurve.ConfidenceIntervalLower.ToString());
System.Diagnostics.Debug.WriteLine("Upper limit: " + ROCcurve.ConfidenceIntervalUpper.ToString());
System.Diagnostics.Debug.Unindent();
System.Diagnostics.Debug.WriteLine("Cutoff threshold:");
System.Diagnostics.Debug.Indent();
CutOffPoints := ROCcurve.CutOffPoints;
For i := 0 To CutOffPoints.Length - 1 Do
System.Diagnostics.Debug.WriteLine(CutOffPoints[i]);
End For;
System.Diagnostics.Debug.Unindent();
System.Diagnostics.Debug.Unindent();
// Output decision tree
For i := 0 To GB.Trees.Count1 - 1 Do
For j := 0 To GB.Trees.Count2 - 1 Do
TreeNode := GB.Trees.Item[i, j];
If TreeNode <> Null Then
System.Diagnostics.Debug.Write("Decision tree");
System.Diagnostics.Debug.WriteLine(" [" + i.ToString() + "," + j.ToString() + "]:");
print(TreeNode);
System.Diagnostics.Debug.WriteLine("");
End If;
End For;
End For;
End If;
End Sub;
// Decision tree output procedure
Public Shared Sub print(node: IBinaryTreeNode);
Var
i: Integer;
Categorical: Boolean = False;
Begin
System.Diagnostics.Debug.Indent();
System.Diagnostics.Debug.WriteLine("Node No.: " + node.NodeIndex.ToString());
System.Diagnostics.Debug.WriteLine("Number of node cases: " + node.Total.ToString());
System.Diagnostics.Debug.WriteLine("Criterion index: " + node.ExplanatorieIndex.ToString());
System.Diagnostics.Debug.WriteLine("Criterion name: " + node.Name);
System.Diagnostics.Debug.Write("Criterion type: ");
Select Case node.PropertyType
Case
DecisionTreePropertyType.dtptCategorical: System.Diagnostics.Debug.WriteLine("categorical");
Categorical := True;
Case DecisionTreePropertyType.dtptNoProperty: System.Diagnostics.Debug.WriteLine("-");
Case DecisionTreePropertyType.dtptOrdered: System.Diagnostics.Debug.WriteLine("ordinal");
Case DecisionTreePropertyType.dtptValue: System.Diagnostics.Debug.WriteLine("quantitative");
End Select;
If Not Categorical Then
System.Diagnostics.Debug.WriteLine("Criterion value: " + node.Value.ToString());
End If;
System.Diagnostics.Debug.WriteLine("Variance: " + node.Disp.ToString());
System.Diagnostics.Debug.WriteLine("Mean: " + node.Mean.ToString());
System.Diagnostics.Debug.WriteLine("Sum of squared residuals: " + node.SSR.ToString());
If (node.LeftNode <> Null) Then
System.Diagnostics.Debug.WriteLine("Left branch: ");
print(node.LeftNode);
End If;
If (node.LeftNodeCategories.Length <> 0) And Categorical Then
System.Diagnostics.Debug.WriteLine("List of categories that are sent to the left branch: ");
For i := 0 To node.LeftNodeCategories.Length - 1 Do
System.Diagnostics.Debug.WriteLine(node.LeftNodeCategories.GetValue(i));
End For;
End If;
If (node.RightNode <> Null) Then
System.Diagnostics.Debug.WriteLine("Right branch: ");
print(node.RightNode);
End If;
If (node.RightNodeCategories.Length <> 0) And Categorical Then
System.Diagnostics.Debug.WriteLine("List of categories that are sent to the right branch: ");
For i := 0 To node.RightNodeCategories.Length - 1 Do
System.Diagnostics.Debug.WriteLine(node.RightNodeCategories.GetValue(i));
End For;
End If;
System.Diagnostics.Debug.Unindent(); ;
End Sub print;
See also: