Skip to content

Commit

Permalink
[MRG+1] GaussianProcessRegressor: faster prediction of std (scikit-le…
Browse files Browse the repository at this point in the history
  • Loading branch information
hbertrand authored and herilalaina committed Mar 26, 2017
1 parent 196491a commit 3d29c61
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc/whats_new.rst
Expand Up @@ -154,6 +154,9 @@ Enhancements
- Add ``sample_weight`` parameter to :func:`metrics.cohen_kappa_score` by
Victor Poughon.

- In :class:`gaussian_process.GaussianProcessRegressor`, method ``predict``
is a lot faster with ``return_std=True`` by :user:`Hadrien Bertrand <hbertrand>`.

Bug fixes
.........
- Fixed a bug where :class:`sklearn.ensemble.IsolationForest` uses an
Expand Down
2 changes: 1 addition & 1 deletion sklearn/gaussian_process/gpr.py
Expand Up @@ -312,7 +312,7 @@ def predict(self, X, return_std=False, return_cov=False):
K_inv = L_inv.dot(L_inv.T)
# Compute variance of predictive distribution
y_var = self.kernel_.diag(X)
y_var -= np.einsum("ki,kj,ij->k", K_trans, K_trans, K_inv)
y_var -= np.einsum("ij,ij->i", np.dot(K_trans, K_inv), K_trans)

# Check if any of the variances is negative because of
# numerical issues. If yes: set the variance to 0.
Expand Down

0 comments on commit 3d29c61

Please sign in to comment.