Create `n_trees`-worth of bootstrapped samples from the training data and use each to fit a separate decision tree.
(self, X, Y)
| 42 | self.classifier = classifier |
| 43 | |
| 44 | def fit(self, X, Y): |
| 45 | """ |
| 46 | Create `n_trees`-worth of bootstrapped samples from the training data |
| 47 | and use each to fit a separate decision tree. |
| 48 | """ |
| 49 | self.trees = [] |
| 50 | for _ in range(self.n_trees): |
| 51 | X_samp, Y_samp = bootstrap_sample(X, Y) |
| 52 | tree = DecisionTree( |
| 53 | n_feats=self.n_feats, |
| 54 | max_depth=self.max_depth, |
| 55 | criterion=self.criterion, |
| 56 | classifier=self.classifier, |
| 57 | ) |
| 58 | tree.fit(X_samp, Y_samp) |
| 59 | self.trees.append(tree) |
| 60 | |
| 61 | def predict(self, X): |
| 62 | """ |