MCPcopy Index your code
hub / github.com/ddbourgin/numpy-ml / predict

Method predict

numpy_ml/linear_models/naive_bayes.py:128–143  ·  view source on GitHub ↗

Use the trained classifier to predict the class label for each example in **X**. Parameters ---------- X: :py:class:`ndarray ` of shape `(N, M)` A dataset of `N` examples, each of dimension `M` Returns -------

(self, X)

Source from the content-addressed store, hash-verified

126 return self
127
128 def predict(self, X):
129 """
130 Use the trained classifier to predict the class label for each example
131 in **X**.
132
133 Parameters
134 ----------
135 X: :py:class:`ndarray <numpy.ndarray>` of shape `(N, M)`
136 A dataset of `N` examples, each of dimension `M`
137
138 Returns
139 -------
140 labels : :py:class:`ndarray <numpy.ndarray>` of shape `(N)`
141 The predicted class labels for each example in `X`
142 """
143 return self.labels[self._log_posterior(X).argmax(axis=1)]
144
145 def _log_posterior(self, X):
146 r"""

Callers 1

test_GaussianNBFunction · 0.95

Calls 1

_log_posteriorMethod · 0.95

Tested by 1

test_GaussianNBFunction · 0.76