r""" Use the trained model to generate predictions for the distribution means, :math:`\mu`, associated with the collection of data points in **X**. Parameters ---------- X : :py:class:`ndarray ` of shape `(Z, M)` A dataset c
(self, X)
| 185 | return self |
| 186 | |
| 187 | def predict(self, X): |
| 188 | r""" |
| 189 | Use the trained model to generate predictions for the distribution |
| 190 | means, :math:`\mu`, associated with the collection of data points in |
| 191 | **X**. |
| 192 | |
| 193 | Parameters |
| 194 | ---------- |
| 195 | X : :py:class:`ndarray <numpy.ndarray>` of shape `(Z, M)` |
| 196 | A dataset consisting of `Z` new examples, each of dimension `M`. |
| 197 | |
| 198 | Returns |
| 199 | ------- |
| 200 | mu_pred : :py:class:`ndarray <numpy.ndarray>` of shape `(Z,)` |
| 201 | The model predictions for the expected value of the target |
| 202 | associated with each item in `X`. |
| 203 | """ |
| 204 | assert self._is_fit, "Must call `fit` before generating predictions" |
| 205 | L = _GLM_LINKS[self.link] |
| 206 | |
| 207 | # convert X to a design matrix if we're using an intercept |
| 208 | if self.fit_intercept: |
| 209 | X = np.c_[np.ones(X.shape[0]), X] |
| 210 | |
| 211 | mu_pred = L["inv_link"](X @ self.beta) |
| 212 | return mu_pred.ravel() |