MCPcopy
hub / github.com/ddbourgin/numpy-ml / fit

Method fit

numpy_ml/trees/dt.py:70–85  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 """

Callers 14

fitMethod · 0.95
fitMethod · 0.95
plotFunction · 0.95
test_DecisionTreeFunction · 0.95
test_RandomForestFunction · 0.45
test_gbdtFunction · 0.45
test_linear_regressionFunction · 0.45
test_GaussianNBFunction · 0.45
test_knn_regressionFunction · 0.45
test_knn_clfFunction · 0.45
test_gp_regressionFunction · 0.45
test_glmFunction · 0.45

Calls 1

_growMethod · 0.95

Tested by 11

test_DecisionTreeFunction · 0.76
test_RandomForestFunction · 0.36
test_gbdtFunction · 0.36
test_linear_regressionFunction · 0.36
test_GaussianNBFunction · 0.36
test_knn_regressionFunction · 0.36
test_knn_clfFunction · 0.36
test_gp_regressionFunction · 0.36
test_glmFunction · 0.36
trainMethod · 0.36
trainMethod · 0.36