Predict the target value for each entry in `X`. Parameters ---------- X : :py:class:`ndarray ` of shape `(N, M)` The training data of `N` examples, each with `M` features. Returns ------- y_pred : :py:class:`ndarra
(self, X)
| 59 | self.trees.append(tree) |
| 60 | |
| 61 | def predict(self, X): |
| 62 | """ |
| 63 | Predict the target value for each entry in `X`. |
| 64 | |
| 65 | Parameters |
| 66 | ---------- |
| 67 | X : :py:class:`ndarray <numpy.ndarray>` of shape `(N, M)` |
| 68 | The training data of `N` examples, each with `M` features. |
| 69 | |
| 70 | Returns |
| 71 | ------- |
| 72 | y_pred : :py:class:`ndarray <numpy.ndarray>` of shape `(N,)` |
| 73 | Model predictions for each entry in `X`. |
| 74 | """ |
| 75 | tree_preds = np.array([[t._traverse(x, t.root) for x in X] for t in self.trees]) |
| 76 | return self._vote(tree_preds) |
| 77 | |
| 78 | def _vote(self, predictions): |
| 79 | """ |