Class DecisionNode
A decision node represent a decision. A decision tree consists of these nodes.
def __init__(self, id_feature, *, threshold=0.5, operator=OperatorCondition.GE, left, right, parent=None): Highlight
A DecisionNode represents a condition “<id_feature> <operator> <threshold> ?” (such as “$x_4 ≥ 0.5$ ?”) in the model while a LeafNode is a value.
During the process, can also create two or one LeafNode without returning it.
Parameters
id_feature : int
The feature identifier used in the condition ”<id_feature> <operator> <threshold> ?”.
operator : OperatorCondition str, default=OperatorCondition.GE
The operator used in the condition ”<id_feature> <operator> <threshold> ?”.
Possible values are defined in the OperatorCondition enum.
threshold : float, default=0.5
The threshold used in the condition ”<id_feature> <operator> <threshold> ?”.
parent : DecisionNode None (optional, default=None)
To define the parent of this node. If this parameter is set to None, the parent is automatically defined when the tree is created.
left : DecisionNode Integer Float
The left child of the node. When this parameter is an Integer or a Float, a LeafNode is generated.
right : DecisionNode Integer Float
The left child of the node. When this parameter is an Integer or a Float, a LeafNode is generated.
Examples
node_v3_1 = Builder.DecisionNode(3, operator="EQ", threshold=1, left=0, right=1)
node_v2_1 = Builder.DecisionNode(2, operator="EQ", threshold=1, left=0, right=node_v3_1)
When the operator and threshold parameters are not defined, they take their default values.
In this case, the associated condition is of the form “$x ≥ 0.5$ ?”