IBinaryTreeNode.Value

Syntax

Value: Double;

Description

The Value property returns the checked value.

Comments

To get the number of explanatory series, by which node is divided, use the IBinaryTreeNode.ExplanatorieIndex property.

If criterion is categorical, Value returns empty value.

Example

Add a link to the Stat system assembly.

Sub UserProc;
Var
    rf: SmRandomForest;
    Y: Array[16Of Integer;
    X1,X2: Array[16Of Double;
    res, i: Integer;
    Explanatories: ISlSeries;
    Explan: ISlSerie;
    Forest: IBinaryTreeForest;
    TreeNode: IBinaryTreeNode;
Begin
    rf := New SmRandomForest.Create;
    // Set explained series
    Y[00] := 0; Y[08] := 1;
    Y[01] := 1; Y[09] := 0;
    Y[02] := 0; Y[10] := 2;
    Y[03] := 2; Y[11] := 2;
    Y[04] := 1; Y[12] := 1;
    Y[05] := 1; Y[13] := 2;
    Y[06] := 2; Y[14] := 0;
    Y[07] := 1; Y[15] := 2;
    rf.Dependent := Y;
    // Set explanatory series (integer)
    X1[00] := 34.13; X1[08] := 29.27;
    X1[01] := 21.52; X1[09] := 23.39;
    X1[02] := 25.43; X1[10] := 28.28;
    X1[03] := 43.42; X1[11] := 43.55;
    X1[04] := 40.19; X1[12] := 44.80;
    X1[05] := 24.97; X1[13] := 23.23;
    X1[06] := 20.57; X1[14] := 37.14;
    X1[07] := 30.81; X1[15] := 27.44;
    Explanatories := rf.ExplanatoriesContinuous;
    Explanatories.Clear;
    Explan := Explanatories.Add;
    Explan.Id := "Continuous_X1";
    Explan.Name := "X1";
    Explan.Value := X1;
    X2[00] := 13;    X2[08] := 91.27;
    X2[01] := 1.5;   X2[09] := 43.39;
    X2[02] := 25;    X2[10] := 68.28;
    X2[03] := 4.42;  X2[11] := 0.55;
    X2[04] := 40.9;  X2[12] := 2.80;
    X2[05] := 45.97; X2[13] := 1.23;
    X2[06] := 13.57; X2[14] := 37.14;
    X2[07] := 0.81;  X2[15] := 5.44;
    Explan := Explanatories.Add;
    Explan.Id := "Continuous_X2";
    Explan.Name := "X2";
    Explan.Value := X2;
    // Forest size
    rf.ForestSize := 5;
    // Trees size
    rf.TreeSizeSpecification.MaximumNumberOfLevels := 2;
    rf.TreeSizeSpecification.MinimumNumberOfCases := 1;
    // Perform calculation and display error  messages
    res:=rf.Execute;
    If (res = 0Then
        Forest := rf.Forest;
        Debug.WriteLine("Number of trees in ensemble: "+Forest.Count.ToString);
        For i := 0 To Forest.Count - 1 Do
            TreeNode := Forest.Item(i);
            Debug.WriteLine("Tree "+(i+1).ToString);
            Debug.WriteLine(" Root node");
            print(TreeNode);
        End For;
        Else
            Debug.WriteLine(rf.Errors);
    End If;
End Sub UserProc;

Sub print(node: IBinaryTreeNode);
Var
    i: integer;
    Categorical: Boolean = False;
Begin
    Debug.WriteLine("  Number of node in tree: " + node.NodeIndex.ToString);
    If node.Parent <> Null Then
        Debug.WriteLine("  Root node: " + node.Parent.Name);
    End If;
    Debug.WriteLine("  Number of observations in node: " + node.Total.ToString);
    Debug.WriteLine("  Classifying variable name: " + node.Name);
    Debug.WriteLine("  Explanatory series number: " + node.ExplanatorieIndex.ToString);
    Debug.WriteLine("  Improvement coefficient: " + node.Improvement.ToString);
    Debug.Write("  Classifying variable 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("  Verified value: " + node.Value.ToString);
    End If;
        For i := 0 To node.Categories.Length - 1 Do
        Debug.WriteLine("  Category: " + node.Categories[i].ToString);
    End For;
    Debug.Indent;
    If (node.LeftNode <> NullThen
        Debug.WriteLine("Left branch");
        print(node.LeftNode);
    End If;
    Debug.Unindent;
    Debug.Indent;
    If(node.RightNode <> NullThen
        Debug.WriteLine("Right branch");
        print(node.RightNode);
    End If;
    Debug.Unindent;
End Sub print;

After executing the example the console window displays:

See also:

IBinaryTreeNode