如何组合两个GPy模型的情节?

2024-04-25 13:43:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经计算了两个GP回归模型,并希望将它们绘制在同一个图形中。在

模型1

kernel = GPy.kern.RBF(input_dim=1, variance=.1, lengthscale=1.)
m1 = GPy.models.GPRegression(xa, ya,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(fig2, filename='2')

型号2

^{2}$

我希望两个图形都在一个图形中,可以是matplotlib,也可以是plotly,即GPy.plotting.show(fig, filename='filename')。在

谢谢


Tags: 模型true图形plotshowdisplayplottingfilename
1条回答
网友
1楼 · 发布于 2024-04-25 13:43:35

使用matplotlib,您可以定义一个子批次,并使用相同的轴指定要使用的子批次(特别是paramax)。在

import matplotlib.plt as plt
fig, ax = plt.subplots()
m1.plot(plot_density=True, ax=ax)
m2.plot(plot_density=True, ax=ax)

我用一个测试数据集测试了这一点:

^{pr2}$

相关: What is the best way of combining two independent plots with matplotlib?

Plot of two densities w/data

相关问题 更多 >