Class RandomForest
def __init__(self, forest, n_features=None, n_classes=None, learner_information=None, feature_names=None, class_names=None): Highlight
Returns a RandomForest consisting of trees (the forest) and n_classes to predict.
Parameters
forest : list of DecisionTree
The list of trees composing the random forest.
n_classes : int
The number of classes to predict (can be multi-class).
learner_information : LearnerInformation (optional, default=LearnerInformation(problem_type=’classification’) if called from Builder else None)
The information about the learning process.
feature_names : list of str (optional, default=None)
The names of the features used in the model.
class_names : list of str (optional, default=None)
The names of the classes to predict.
Examples
node_t1_v1_1 = Builder.DecisionNode(1, operator=Builder.GE, threshold=10, left=0, right=0)
node_t1_v1_2 = Builder.DecisionNode(1, operator=Builder.GE, threshold=20, left=node_t1_v1_1, right=0)
node_t1_v1_3 = Builder.DecisionNode(1, operator=Builder.GE, threshold=30, left=node_t1_v1_2, right=1)
node_t1_v1_4 = Builder.DecisionNode(1, operator=Builder.GE, threshold=40, left=node_t1_v1_3, right=1)
tree_1 = Builder.DecisionTree(3, node_t1_v1_4)
node_t2_v3 = Builder.DecisionNode(3, operator=Builder.EQ, threshold=1, left=0, right=1)
node_t2_v2 = Builder.DecisionNode(2, operator=Builder.EQ, threshold=1, left=0, right=node_t2_v3)
tree_2 = Builder.DecisionTree(3, node_t2_v2)
tree_3 = Builder.DecisionTree(3, Builder.LeafNode(1))
forest = Builder.RandomForest([tree_1, tree_2, tree_3], n_classes=2)