Return the MAP estimate for :math:`y^*`, corresponding the mean/mode of the posterior predictive distribution, :math:`p(y^* \mid x^*, X, y)`. Notes ----- Under the GP regression model, the posterior predictive distribution is .. math::
(self, X, conf_interval=0.95, return_cov=False)
| 62 | self.parameters["GP_mean"] = mu |
| 63 | |
| 64 | def predict(self, X, conf_interval=0.95, return_cov=False): |
| 65 | """ |
| 66 | Return the MAP estimate for :math:`y^*`, corresponding the mean/mode of |
| 67 | the posterior predictive distribution, :math:`p(y^* \mid x^*, X, y)`. |
| 68 | |
| 69 | Notes |
| 70 | ----- |
| 71 | Under the GP regression model, the posterior predictive distribution is |
| 72 | |
| 73 | .. math:: |
| 74 | |
| 75 | y^* \mid x^*, X, y \sim \mathcal{N}(\mu^*, \\text{cov}^*) |
| 76 | |
| 77 | where |
| 78 | |
| 79 | .. math:: |
| 80 | |
| 81 | \mu^* &= K^* (K + \\alpha I)^{-1} y \\\\ |
| 82 | \\text{cov}^* &= K^{**} - K^{*'} (K + \\alpha I)^{-1} K^* |
| 83 | |
| 84 | and |
| 85 | |
| 86 | .. math:: |
| 87 | |
| 88 | K &= \\text{kernel}(X, X) \\\\ |
| 89 | K^* &= \\text{kernel}(X, X^*) \\\\ |
| 90 | K^{**} &= \\text{kernel}(X^*, X^*) |
| 91 | |
| 92 | NB. This implementation uses the inefficient but general purpose |
| 93 | `np.linalg.inv` routine to invert :math:`(K + \\alpha I)`. A more |
| 94 | efficient way is to rely on the fact that `K` (and hence also :math:`K |
| 95 | + \\alpha I`) is symmetric positive (semi-)definite and take the inner |
| 96 | product of the inverse of its (lower) Cholesky decompositions: |
| 97 | |
| 98 | .. math:: |
| 99 | |
| 100 | Q^{-1} = \\text{cholesky}(Q)^{-1 \\top} \\text{cholesky}(Q)^{-1} |
| 101 | |
| 102 | For more details on a production-grade implementation, see Algorithm |
| 103 | 2.1 in Rasmussen & Williams (2006). |
| 104 | |
| 105 | Parameters |
| 106 | ---------- |
| 107 | X : :py:class:`ndarray <numpy.ndarray>` of shape (N, M) |
| 108 | The collection of datapoints to generate predictions on |
| 109 | conf_interval : float in (0, 1) |
| 110 | The percentage confidence bound to return for each prediction. If |
| 111 | the scipy package is not available, this value is always set to |
| 112 | 0.95. Default is 0.95. |
| 113 | return_cov : bool |
| 114 | If True, also return the covariance (`cov*`) of the posterior |
| 115 | predictive distribution for the points in `X`. Default is False. |
| 116 | |
| 117 | Returns |
| 118 | ------- |
| 119 | y_pred : :py:class:`ndarray <numpy.ndarray>` of shape `(N, O)` |
| 120 | The predicted values for each point in `X`, each with |
| 121 | dimensionality `O`. |
no outgoing calls