test_method_examples.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:smt 作者: SMTorg 项目源码 文件源码
def test_ls(self):
        import numpy as np
        import matplotlib.pyplot as plt

        from smt.methods import LS

        xt = np.array([0., 1., 2., 3., 4.])
        yt = np.array([0., 1., 1.5, 0.5, 1.0])

        sm = LS()
        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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号