SheffieldML / GPy

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

Combine plot of two GPy models #760

Open meechos opened 5 years ago

meechos commented 5 years ago

I have calculated two GP regression models and would like to have them plotted in the same figure. For example:

Model 1

kernel = GPy.kern.RBF(input_dim=1, variance=.1, lengthscale=1.)
m1 = GPy.models.GPRegression(x1, y1,kernel)
m1.optimize_restarts(num_restarts = 10)
m1.optimize(messages=True)

from IPython.display import display
display(m1)

fig1 = m1.plot(plot_density=True) 
m1.plot(plot_density=True)
GPy.plotting.show(fig1, filename='2')

Model 2

m2 = GPy.models.GPRegression(x2, y2,kernel)
m2.optimize_restarts(num_restarts = 10)
m2.optimize(messages=True)

from IPython.display import display
display(m2)

fig2 = m2.plot(plot_density=True,)

GPy.plotting.show(fig2, filename='2')

This gives out two separate figures but I would like but would like to plot both in one. Implementation on ither matplotlib or plotly i.e. GPy.plotting.show(fig, filename='filename') would be fine.

Apologies if the question is naive. Thanks

daveliu-riviera commented 5 years ago

I answered this question just now. :)

https://stackoverflow.com/questions/56289624/how-to-combine-plot-of-two-gpy-models/56350789#56350789