def test_krg(self):
import numpy as np
import matplotlib.pyplot as plt
from smt.methods import KRG
xt = np.array([0., 1., 2., 3., 4.])
yt = np.array([0., 1., 1.5, 0.5, 1.0])
sm = KRG(theta0=[1e-2])
sm.set_training_values(xt, yt)
sm.train()
num = 100
x = np.linspace(0., 4., num)
y = sm.predict_values(x)
plt.plot(xt, yt, 'o')
plt.plot(x, y)
plt.xlabel('x')
plt.ylabel('y')
plt.legend(['Training data', 'Prediction'])
plt.show()
评论列表
文章目录