Python GPy模块:如何绘制简单x轴上的模型预测?

Python GPy模块:如何绘制简单x轴上的模型预测?,python,machine-learning,plot,plotly,Python,Machine Learning,Plot,Plotly,在Python中,我试图深入到库中以估计高斯过程模型,但在早期的简单绘图中遇到了一个绊脚石 对于我的数据,我生成了一个简单的正弦波,中间加上一个平方增长率,GPy成功地估计了初始模型 数据生成: ## Generating data for regression # First, regular sine wave + normal noise x = np.linspace(0,40, num=300) noise1 = np.random.normal(0,0.3,300) y = np.s

在Python中,我试图深入到库中以估计高斯过程模型,但在早期的简单绘图中遇到了一个绊脚石

对于我的数据,我生成了一个简单的正弦波,中间加上一个平方增长率,GPy成功地估计了初始模型

数据生成:

## Generating data for regression
# First, regular sine wave + normal noise
x = np.linspace(0,40, num=300)
noise1 = np.random.normal(0,0.3,300)
y = np.sin(x) + noise1

# Second, an upward trending starting midway, with its own noise as well
temp = x[150:]
noise2 = 0.004*temp**2 + np.random.normal(0,0.1,150)
y[150:] = y[150:] + noise2

plt.plot(x, y)
初始模型:

## Pre-processing
X = np.expand_dims(x, axis=1)
Y = np.expand_dims(y, axis=1)

## Model
kernel = GPy.kern.RBF(input_dim=1, variance=1., lengthscale=1.)
model1 = GPy.models.GPRegression(X, Y, kernel)

## Plotting
fig = model1.plot()
GPy.plotting.show(fig, filename='basic_gp_regression_notebook')

但是,此模型指定错误,因为数据仅使用sin(X)和X^2创建,而不仅仅是X,因此我创建了下一个模型:

X_all = np.hstack((np.sin(X), np.square(X)))

model2 = GPy.models.GPRegression(X_all, Y, kernel)

fig = model2.plot()
GPy.plotting.show(fig, filename='basic_correct_gp_regression_notebook')
但是现在,我发现了一些绘图错误

Invalid value of type 'builtins.str' received for the 'size' property of scatter.marker Received value: '5'
我假设这是因为绘图不知道使用“X”作为X轴,因为只提供了sin(X)和X^2

我怎样才能解决这个问题