Use the trained model to generate predictions 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`. Returns
(self, X)
| 216 | return self |
| 217 | |
| 218 | def predict(self, X): |
| 219 | """ |
| 220 | Use the trained model to generate predictions on a new collection of |
| 221 | data points. |
| 222 | |
| 223 | Parameters |
| 224 | ---------- |
| 225 | X : :py:class:`ndarray <numpy.ndarray>` of shape `(Z, M)` |
| 226 | A dataset consisting of `Z` new examples, each of dimension `M`. |
| 227 | |
| 228 | Returns |
| 229 | ------- |
| 230 | y_pred : :py:class:`ndarray <numpy.ndarray>` of shape `(Z, K)` |
| 231 | The model predictions for the items in `X`. |
| 232 | """ |
| 233 | # convert X to a design matrix if we're fitting an intercept |
| 234 | if self.fit_intercept: |
| 235 | X = np.c_[np.ones(X.shape[0]), X] |
| 236 | return X @ self.beta |
no outgoing calls