(self,X,y)
| 177 | return myTree |
| 178 | |
| 179 | def fit(self,X,y): |
| 180 | #类型检查 |
| 181 | if isinstance(X,np.ndarray) and isinstance(y,np.ndarray): |
| 182 | pass |
| 183 | else: |
| 184 | try: |
| 185 | X = np.array(X) |
| 186 | y = np.array(y) |
| 187 | except: |
| 188 | raise TypeError("numpy.ndarray required for X,y") |
| 189 | |
| 190 | featureIndex = tuple(['x'+str(i) for i in range(X.shape[1])]) |
| 191 | self._tree = self._createTree(X,y,featureIndex) |
| 192 | return self #allow chaining: clf.fit().predict() |
| 193 | |
| 194 | |
| 195 |
no test coverage detected