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

Method predict

numpy_ml/trees/dt.py:87–102  ·  view source on GitHub ↗

Use the trained decision tree to classify or predict the examples in `X`. Parameters ---------- X : :py:class:`ndarray ` of shape `(N, M)` The training data of `N` examples, each with `M` features Returns ------- p

(self, X)

Source from the content-addressed store, hash-verified

85 self.root = self._grow(X, Y)
86
87 def predict(self, X):
88 """
89 Use the trained decision tree to classify or predict the examples in `X`.
90
91 Parameters
92 ----------
93 X : :py:class:`ndarray <numpy.ndarray>` of shape `(N, M)`
94 The training data of `N` examples, each with `M` features
95
96 Returns
97 -------
98 preds : :py:class:`ndarray <numpy.ndarray>` of shape `(N,)`
99 The integer class labels predicted for each example in `X` if
100 self.classifier = True, otherwise the predicted target values.
101 """
102 return np.array([self._traverse(x, self.root) for x in X])
103
104 def predict_class_probs(self, X):
105 """

Callers 11

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

_traverseMethod · 0.95

Tested by 9

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