function train_forest(data, num_trees):

   trees = []
   for i in range(num_trees):
      sample = bootstrap_sample(data) # random rows, with replace
 ment
      tree = train_tree(sample, random_feature_subset=true)
      trees.append(tree)
   return trees


 function predict_forest(x, trees):
   votes = [tree.predict(x) for tree in trees]
   return majority_vote(votes) # averaging cancels out individual trees' mist
 akes
