Skip to content

Instantly share code, notes, and snippets.

@beckdaniel
Created February 26, 2016 13:02
Show Gist options
  • Save beckdaniel/ac44ae59d223fde3e5c7 to your computer and use it in GitHub Desktop.
Save beckdaniel/ac44ae59d223fde3e5c7 to your computer and use it in GitHub Desktop.
GPflow vs. GPy
import GPy
import GPflow
import numpy as np
rng = np.random.RandomState(0)
X = rng.randn(100,2)
Y = rng.randn(100,1)
Xtest = rng.randn(10,2)
# GPy
m_gpy = GPy.models.GPRegression(X, Y)
# GPflow
m_gpflow = GPflow.gpr.GPR(X, Y, GPflow.kernels.RBF(1))
print m_gpy
print m_gpflow
print m_gpy.predict(Xtest)
print m_gpflow.predict_y(Xtest)
# Expected output
"""
Name : GP regression
Objective : 144.20800383
Number of Parameters : 3
Number of Optimization Parameters : 3
Updates : True
Parameters:
GP_regression. | value | constraints | priors
rbf.variance | 1.0 | +ve |
rbf.lengthscale | 1.0 | +ve |
Gaussian_noise.variance | 1.0 | +ve |
model.likelihood.variance transform:+ve prior:None
[ 1.]
model.kern.lengthscales transform:+ve prior:None
[ 1.]
model.kern.variance transform:+ve prior:None
[ 1.]
(array([[-0.15199914],
[-0.26766372],
[-0.38295276],
[ 0.01115626],
[-0.31434469],
[-0.46805395],
[ 0.03996755],
[-0.14441124],
[-0.30056849],
[-0.27920849]]), array([[ 1.17194185],
[ 1.07740217],
[ 1.0767739 ],
[ 1.2536379 ],
[ 1.06700106],
[ 1.090615 ],
[ 1.12538894],
[ 1.06045394],
[ 1.06845334],
[ 1.06448736]]))
[array([[ 0.03072267],
[-0.32096233],
[-0.19599798],
[ 0.03379334],
[-0.18174901],
[-0.31749606],
[ 0.00391937],
[-0.23998849],
[-0.33504122],
[-0.33190934]]), array([[ 1.04870813],
[ 1.02989084],
[ 1.03347398],
[ 1.0515597 ],
[ 1.03393089],
[ 1.02983322],
[ 1.03524757],
[ 1.02843413],
[ 1.03012201],
[ 1.03007054]])]
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment