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)
| 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 | |
| 171 | def _sigmoid(x): |
no test coverage detected