SheffieldML / GPy

Gaussian processes framework in python
BSD 3-Clause "New" or "Revised" License
2.04k stars 562 forks source link

marginal likelihood of testing? #768

Open whungt opened 5 years ago

whungt commented 5 years ago

Hi guys,

It seems that the objective of the model is the negative log marginal likelihood calculated on training data. Is there any existing function to calculate the marginal likelihood in the testing period? If not, where can we get the covariance matrix to calculate it?

Thanks in advance

alexey-pronkin commented 4 years ago

Hi, you can use "model.inference_method.inference" method; For example:

def test_log_likelihood(model, X_test, ytest): , test_loglikelihood, = model.inference_method.inference(model.kern, X_test, model.likelihood, y_test, model.mean_function, model.Y_metadata) return test_log_likelihood

Note that you need normalize y_test as y_train. (You can use model.normalizer.normalize if you define normalize=True in model parameters.)