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

Method predict

numpy_ml/linear_models/logistic.py:150–168  ·  view source on GitHub ↗

Use the trained model to generate prediction probabilities on a new collection of data points. Parameters ---------- X : :py:class:`ndarray ` of shape `(Z, M)` A dataset consisting of `Z` new examples, each of dimension `M`.

(self, X)

Source from the content-addressed store, hash-verified

148 return -((y - y_pred) @ X + d_penalty) / N
149
150 def predict(self, X):
151 """
152 Use the trained model to generate prediction probabilities on a new
153 collection of data points.
154
155 Parameters
156 ----------
157 X : :py:class:`ndarray <numpy.ndarray>` of shape `(Z, M)`
158 A dataset consisting of `Z` new examples, each of dimension `M`.
159
160 Returns
161 -------
162 y_pred : :py:class:`ndarray <numpy.ndarray>` of shape `(Z,)`
163 The model prediction probabilities for the items in `X`.
164 """
165 # convert X to a design matrix if we're fitting an intercept
166 if self.fit_intercept:
167 X = np.c_[np.ones(X.shape[0]), X]
168 return _sigmoid(X @ self.beta)
169
170
171def _sigmoid(x):

Callers 1

plot_logisticFunction · 0.95

Calls 1

_sigmoidFunction · 0.85

Tested by

no test coverage detected