10000 [MRG+1] GaussianProcessRegressor: faster prediction of std (#8591) · massich/scikit-learn@9ef6a66 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9ef6a66

Browse files
hbertrandJoan Massich
authored andcommitted
[MRG+1] GaussianProcessRegressor: faster prediction of std (scikit-learn#8591)
1 parent de59d65 commit 9ef6a66

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

doc/whats_new.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ Enhancements
154154
- Add ``sample_weight`` parameter to :func:`metrics.cohen_kappa_score` by
155155
Victor Poughon.
156156

157+
- In :class:`gaussian_process.GaussianProcessRegressor`, method ``predict``
158+
is a lot faster with ``return_std=True`` by :user:`Hadrien Bertrand <hbertrand>`.
159+
157160
Bug fixes
158161
.........
159162
- Fixed a bug where :class:`sklearn.ensemble.IsolationForest` uses an

sklearn/gaussian_process/gpr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def predict(self, X, return_std=False, return_cov=False):
312312
K_inv = L_inv.dot(L_inv.T)
313313
# Compute variance of predictive distribution
314314
y_var = self.kernel_.diag(X)
315-
y_var -= np.einsum("ki,kj,ij->k", K_trans, K_trans, K_inv)
315+
y_var -= np.einsum("ij,ij->i", np.dot(K_trans, K_inv), K_trans)
316316

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

0 commit comments

Comments
 (0)
0