Fit a binary decision tree to a dataset. Parameters ---------- X : :py:class:`ndarray ` of shape `(N, M)` The training data of `N` examples, each with `M` features Y : :py:class:`ndarray ` of shape `(N,)`
(self, X, Y)
| 68 | raise ValueError("`mse` is a valid criterion only when classifier = False.") |
| 69 | |
| 70 | def fit(self, X, Y): |
| 71 | """ |
| 72 | Fit a binary decision tree to a dataset. |
| 73 | |
| 74 | Parameters |
| 75 | ---------- |
| 76 | X : :py:class:`ndarray <numpy.ndarray>` of shape `(N, M)` |
| 77 | The training data of `N` examples, each with `M` features |
| 78 | Y : :py:class:`ndarray <numpy.ndarray>` of shape `(N,)` |
| 79 | An array of integer class labels for each example in `X` if |
| 80 | self.classifier = True, otherwise the set of target values for |
| 81 | each example in `X`. |
| 82 | """ |
| 83 | self.n_classes = max(Y) + 1 if self.classifier else None |
| 84 | self.n_feats = X.shape[1] if not self.n_feats else min(self.n_feats, X.shape[1]) |
| 85 | self.root = self._grow(X, Y) |
| 86 | |
| 87 | def predict(self, X): |
| 88 | """ |