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

Method predict

numpy_ml/trees/rf.py:61–76  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 2

plotFunction · 0.95
test_RandomForestFunction · 0.95

Calls 2

_voteMethod · 0.95
_traverseMethod · 0.80

Tested by 1

test_RandomForestFunction · 0.76