Class: HybridForest::Forests::ForestGrowers::HybridGrower

Inherits:
Object
  • Object
show all
Defined in:
lib/hybridforest/forests/forest_growers/hybrid_grower.rb

Constant Summary collapse

TREE_TYPES =
[HybridForest::Trees::CARTTree, HybridForest::Trees::ID3Tree].freeze

Instance Method Summary collapse

Instance Method Details

#grow_forest(instances, number_of_trees) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/hybridforest/forests/forest_growers/hybrid_grower.rb', line 11

def grow_forest(instances, number_of_trees)
  forest = []
  number_of_trees.times do
    iob_data, oob_data, oob_labels = HybridForest::Utils.train_test_bootstrap_split(instances)
    trees = grow_trees(TREE_TYPES, iob_data)
    tree_results = predict_evaluate_trees(trees, oob_data, oob_labels)
    best_tree = select_best_tree(tree_results)
    forest << best_tree
  end
  forest
end