Skip to content

[MRG] GaussianProcess improve tests coverage and fix prediction in batches #2687

Closed
wants to merge 4 commits into from

5 participants

@arpangarg

No description provided.

@coveralls

Coverage Status

Coverage remained the same when pulling a201c42 on arpangarg:tests_gaussian_process into 0a8538e on scikit-learn:master.

@agramfort agramfort commented on an outdated diff Dec 26, 2013
sklearn/gaussian_process/gaussian_process.py
@@ -520,9 +526,7 @@ def predict(self, X, eval_MSE=False, batch_size=None):
return y, MSE
else:
-
- y = np.zeros(n_eval)
- for k in range(max(1, n_eval / batch_size)):
+ for k in range(max(1, n_eval / batch_size + 1)):
@agramfort
scikit-learn member
agramfort added a note Dec 26, 2013

use // to force integer division

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@agramfort agramfort commented on an outdated diff Dec 26, 2013
sklearn/gaussian_process/gaussian_process.py
if eval_MSE:
- y, MSE = np.zeros(n_eval), np.zeros(n_eval)
- for k in range(max(1, n_eval / batch_size)):
+ MSE = np.zeros(n_eval)
+ for k in range(max(1, n_eval / batch_size + 1)):
@agramfort
scikit-learn member
agramfort added a note Dec 26, 2013

use // to force integer division

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@agramfort agramfort commented on an outdated diff Dec 26, 2013
sklearn/gaussian_process/tests/test_gaussian_process.py
@@ -135,3 +141,41 @@ def test_no_normalize():
gp = GaussianProcess(normalize=False).fit(X, y)
y_pred = gp.predict(X)
assert_true(np.allclose(y_pred, y))
+
+
+def test_generalized_exponential_corr():
+ '''
+ Test the generalized_exponential correlation model for different values
+ of the exponent
+ '''
+ exponent = [0.1, 1, 2, 4, 5]
+
+ for exp in exponent:
+ gpe = GaussianProcess(regr='quadratic', corr='generalized_exponential',
+ theta0=[1e-2, exp], thetaL=[1e-4]*2,
+ thetaU=[1e-1]*2, random_start=10,
@agramfort
scikit-learn member
agramfort added a note Dec 26, 2013

pep8 : [1e-1]*2 -> [1e-1] * 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@agramfort
scikit-learn member

any GP expert can have a look?

cc @dubourg

@amueller
scikit-learn member

@arpangarg Could you please briefly explain the changes to the gp class?

@coveralls

Coverage Status

Coverage remained the same when pulling e48ffd0 on arpangarg:tests_gaussian_process into cf7cc70 on scikit-learn:master.

@arpangarg

@amueller I noticed the predict function was broken when batch_size is specified where y.ndim != 1. Also, this pull request improves the overall tests coverage specifically by testing the Welch optimizer, storage_mode parameter and generalized_exponential correlation model which weren't being tested before.

@agramfort
scikit-learn member

LGTM

can you just confirm that tests now are not much longer to run?

@glouppe
scikit-learn member
glouppe commented Dec 30, 2013

can you just confirm that tests now are not much longer to run?

Just checked on my box.

master: 3.49s
this branch: 5.72s

But this is somehow expected I guess since this PR adds 3 more tests.

@agramfort agramfort commented on the diff Jan 7, 2014
sklearn/gaussian_process/gaussian_process.py
if eval_MSE:
- y, MSE = np.zeros(n_eval), np.zeros(n_eval)
- for k in range(max(1, n_eval / batch_size)):
+ MSE = np.zeros(n_eval)
+ for k in range(max(1, n_eval // batch_size + 1)):
@agramfort
scikit-learn member
agramfort added a note Jan 7, 2014

looks like n_eval // batch_size + 1 cannot be lower than 1 to the max is now irrelevant right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@glouppe
scikit-learn member
glouppe commented Oct 19, 2015

The GaussianProcess class has been deprecated. A new implementation can be found into gaussian_process.GaussianProcessClassifier and gaussian_process.GaussianProcessRegressor.

Closing this PR, as it is related to the old implementation.

Thanks for your contribution.

@glouppe glouppe closed this Oct 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.