Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPClassification vs GP - Optimal Hyperparameters #988

Open
jcockayne opened this issue Jul 22, 2022 · 0 comments
Open

GPClassification vs GP - Optimal Hyperparameters #988

jcockayne opened this issue Jul 22, 2022 · 0 comments

Comments

@jcockayne
Copy link

Hi,

I am having a strange issue with optimizing hyperparameters in GP classification. Based on this I understand there are two ways to construct a GP classification model - the first using GPy.models.GPClassification and the second using GPy.core.GP with a RBF kernel, Bernoulli likelihood and an EP inference method specificed. I thought the two were equivalent, but I get different results when trying to optimize hyperparameters with these two methods:

import GPy
import numpy as np
np.random.seed(123)
X1 = np.random.normal(-1, 0.1, size=100)
X2 = np.random.normal(1, 0.1, size=100)
X = np.concatenate([X1, X2])[:,None]
y = np.concatenate([np.ones(100), np.zeros(100)])[:,None]

m0 = GPy.models.GPClassification(X, y)
for i in range(5):
    m0.optimize('bfgs', max_iters=100)

lik = GPy.likelihoods.Bernoulli()
k = GPy.kern.RBF(input_dim=1, variance=1, lengthscale=1)
inf_method = GPy.inference.latent_function_inference.expectation_propagation.EP()
m1 = GPy.core.GP(X=X, Y=y, kernel=k, likelihood=lik, inference_method=inf_method)
for i in range(5):
    m1.optimize('bfgs', max_iters=100)

print(m0)
print(m1)

Here m0 and m1 return different hyperparameter values. In a more substantial example I've seen the objective function values and optimal hyperparameters differ even more significantly.

Can someone help to explain the issue? I'm sure I'm just misunderstanding how GP and GPClassification are connected to each other but some help would be appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant