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

Method predict_class_probs

numpy_ml/trees/dt.py:104–120  ·  view source on GitHub ↗

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

(self, X)

Source from the content-addressed store, hash-verified

102 return np.array([self._traverse(x, self.root) for x in X])
103
104 def predict_class_probs(self, X):
105 """
106 Use the trained decision tree to return the class probabilities for the
107 examples in `X`.
108
109 Parameters
110 ----------
111 X : :py:class:`ndarray <numpy.ndarray>` of shape `(N, M)`
112 The training data of `N` examples, each with `M` features
113
114 Returns
115 -------
116 preds : :py:class:`ndarray <numpy.ndarray>` of shape `(N, n_classes)`
117 The class probabilities predicted for each example in `X`.
118 """
119 assert self.classifier, "`predict_class_probs` undefined for classifier = False"
120 return np.array([self._traverse(x, self.root, prob=True) for x in X])
121
122 def _grow(self, X, Y, cur_depth=0):
123 # if all labels are the same, return a leaf

Callers

nothing calls this directly

Calls 1

_traverseMethod · 0.95

Tested by

no test coverage detected