Class DecisionTree
def __init__(self, n_features, root, n_classes=None, force_features_equal_to_binaries=False, learner_information=None, feature_names=None, class_names=None): Highlight
Returns a DecisionTree of n_features which has as root node the root parameter.
Parameters
n_features : int
The total number of features used by all trees of the model (not only those of this DecisionTree)
root : DecisionNode or LeafNode
The root node of the decision tree.
force_features_equal_to_binaries : bool, default=False
Setting this parameter to True ensures that the binary variables are equal to feature identifiers.
Assume that a feature represents a condition (this is not true with most datasets).
Put this option to True only when you build a tree where all features are Boolean conditions.
learner_information : LearnerInformation (optional, default=LearnerInformation(problem_type=’classification’) if called from Builder else None)
The learner information associated to this tree.
feature_names : list of str (optional, default=None)
The names of the features used in this tree.
class_names : list of str (optional, default=None)
The names of the classes used in this tree.
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)
node_v3_2 = Builder.DecisionNode(3, operator="EQ", threshold=1, left=0, right=1)
node_v2_2 = Builder.DecisionNode(2, operator="EQ", threshold=1, left=0, right=node_v3_2)
node_v3_3 = Builder.DecisionNode(3, operator="EQ", threshold=1, left=0, right=1)
node_v2_3 = Builder.DecisionNode(2, operator="EQ", threshold=1, left=0, right=node_v3_3)
node_v1_1 = Builder.DecisionNode(1, operator="GE", threshold=10, left=node_v2_1, right=node_v2_2)
node_v1_2 = Builder.DecisionNode(1, operator="GE", threshold=20, left=node_v1_1, right=node_v2_3)
node_v1_3 = Builder.DecisionNode(1, operator="GE", threshold=30, left=node_v1_2, right=1)
node_v1_4 = Builder.DecisionNode(1, operator="GE", threshold=40, left=node_v1_3, right=1)
tree = Builder.DecisionTree(3, node_v1_4)
When the root parameter is a
LeafNode, the tree contains only one node (the root).