当前位置: 首页>>代码示例>>Python>>正文


Python KrigingSurrogate.predict方法代码示例

本文整理汇总了Python中openmdao.api.KrigingSurrogate.predict方法的典型用法代码示例。如果您正苦于以下问题:Python KrigingSurrogate.predict方法的具体用法?Python KrigingSurrogate.predict怎么用?Python KrigingSurrogate.predict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openmdao.api.KrigingSurrogate的用法示例。


在下文中一共展示了KrigingSurrogate.predict方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_no_training_data

# 需要导入模块: from openmdao.api import KrigingSurrogate [as 别名]
# 或者: from openmdao.api.KrigingSurrogate import predict [as 别名]
    def test_no_training_data(self):
        surrogate = KrigingSurrogate()

        try:
            surrogate.predict([0., 1.])
        except RuntimeError as err:
            self.assertEqual(str(err),
                             "KrigingSurrogate has not been trained, "
                             "so no prediction can be made.")
        else:
            self.fail("RuntimeError Expected")
开发者ID:Mrbarhate,项目名称:OpenMDAO,代码行数:13,代码来源:test_kriging.py

示例2: test_2d

# 需要导入模块: from openmdao.api import KrigingSurrogate [as 别名]
# 或者: from openmdao.api.KrigingSurrogate import predict [as 别名]
    def test_2d(self):

        x = array([[-2., 0.], [-0.5, 1.5], [1., 3.], [8.5, 4.5], [-3.5, 6.], [4., 7.5], [-5., 9.], [5.5, 10.5],
                   [10., 12.], [7., 13.5], [2.5, 15.]])
        y = array([[branin(case)] for case in x])

        surrogate = KrigingSurrogate()
        surrogate.train(x, y)

        for x0, y0 in zip(x, y):
            mu, sigma = surrogate.predict(x0)
            assert_rel_error(self, mu, y0, 1e-9)
            assert_rel_error(self, sigma, 0, 1e-6)

        mu, sigma = surrogate.predict([5., 5.])

        assert_rel_error(self, mu, branin([5., 5.]), 1e-1)
        assert_rel_error(self, sigma, 5.79, 1e-2)
开发者ID:Mrbarhate,项目名称:OpenMDAO,代码行数:20,代码来源:test_kriging.py

示例3: test_2d

# 需要导入模块: from openmdao.api import KrigingSurrogate [as 别名]
# 或者: from openmdao.api.KrigingSurrogate import predict [as 别名]
    def test_2d(self):

        x = np.array([[-2., 0.], [-0.5, 1.5], [1., 3.], [8.5, 4.5], [-3.5, 6.], [4., 7.5], [-5., 9.], [5.5, 10.5],
                   [10., 12.], [7., 13.5], [2.5, 15.]])
        y = np.array([[branin(case)] for case in x])

        surrogate = KrigingSurrogate(nugget=0., eval_rmse=True)
        surrogate.train(x, y)

        for x0, y0 in zip(x, y):
            mu, sigma = surrogate.predict(x0)
            assert_rel_error(self, mu, y0, 1e-9)
            assert_rel_error(self, sigma, 0, 1e-4)

        mu, sigma = surrogate.predict([5., 5.])

        assert_rel_error(self, mu, 16.72, 1e-1)
        assert_rel_error(self, sigma, 15.27, 1e-2)
开发者ID:Satadru-Roy,项目名称:OpenMDAO,代码行数:20,代码来源:test_kriging.py

示例4: test_1d_ill_conditioned

# 需要导入模块: from openmdao.api import KrigingSurrogate [as 别名]
# 或者: from openmdao.api.KrigingSurrogate import predict [as 别名]
 def test_1d_ill_conditioned(self):
     # Test for least squares solver utilization when ill-conditioned
     x = np.array([[case] for case in np.linspace(0., 1., 40)])
     y = np.sin(x)
     surrogate = KrigingSurrogate()
     surrogate.train(x, y)
     new_x = np.array([0.5])
     mu, sigma = surrogate.predict(new_x)
     self.assertTrue(sigma < 3.e-8)
     assert_rel_error(self, mu, np.sin(0.5), 1e-6)
开发者ID:colinxs,项目名称:OpenMDAO,代码行数:12,代码来源:test_kriging.py

示例5: test_1d_training

# 需要导入模块: from openmdao.api import KrigingSurrogate [as 别名]
# 或者: from openmdao.api.KrigingSurrogate import predict [as 别名]
    def test_1d_training(self):

        x = array([[0.0], [2.0], [3.0], [4.0], [6.0]])
        y = array([[branin_1d(case)] for case in x])
        surrogate = KrigingSurrogate()
        surrogate.train(x, y)

        for x0, y0 in zip(x, y):
            mu, sigma = surrogate.predict(x0)
            assert_rel_error(self, mu, y0, 1e-9)
            assert_rel_error(self, sigma, 0, 1e-6)
开发者ID:Mrbarhate,项目名称:OpenMDAO,代码行数:13,代码来源:test_kriging.py

示例6: test_1d_training

# 需要导入模块: from openmdao.api import KrigingSurrogate [as 别名]
# 或者: from openmdao.api.KrigingSurrogate import predict [as 别名]
    def test_1d_training(self):

        x = np.array([[0.0], [2.0], [3.0], [4.0], [6.0]])
        y = np.array([[branin_1d(case)] for case in x])
        surrogate = KrigingSurrogate(nugget=0., eval_rmse=True)
        surrogate.train(x, y)

        for x0, y0 in zip(x, y):
            mu, sigma = surrogate.predict(x0)
            assert_rel_error(self, mu, [y0], 1e-9)
            assert_rel_error(self, sigma, [[0]], 1e-5)
开发者ID:OpenMDAO,项目名称:OpenMDAO,代码行数:13,代码来源:test_kriging.py

示例7: test_1d_predictor

# 需要导入模块: from openmdao.api import KrigingSurrogate [as 别名]
# 或者: from openmdao.api.KrigingSurrogate import predict [as 别名]
    def test_1d_predictor(self):
        x = array([[0.0], [2.0], [3.0], [4.0], [6.0]])
        y = array([[branin_1d(case)] for case in x])

        surrogate = KrigingSurrogate()
        surrogate.train(x, y)

        new_x = array([pi])
        mu, sigma = surrogate.predict(new_x)

        assert_rel_error(self, mu, 0.397887, 1e-1)
        assert_rel_error(self, sigma, 0.0294172, 1e-2)
开发者ID:Mrbarhate,项目名称:OpenMDAO,代码行数:14,代码来源:test_kriging.py

示例8: test_vector_output

# 需要导入模块: from openmdao.api import KrigingSurrogate [as 别名]
# 或者: from openmdao.api.KrigingSurrogate import predict [as 别名]
    def test_vector_output(self):
        surrogate = KrigingSurrogate()

        y = array([[0., 0.], [1., 1.], [2., 0.]])
        x = array([[0.], [2.], [4.]])

        surrogate.train(x, y)

        for x0, y0 in zip(x, y):
            mu, sigma = surrogate.predict(x0)
            assert_rel_error(self, mu, y0, 1e-9)
            assert_rel_error(self, sigma, 0, 1e-6)
开发者ID:Mrbarhate,项目名称:OpenMDAO,代码行数:14,代码来源:test_kriging.py

示例9: test_1d_predictor

# 需要导入模块: from openmdao.api import KrigingSurrogate [as 别名]
# 或者: from openmdao.api.KrigingSurrogate import predict [as 别名]
    def test_1d_predictor(self):
        x = np.array([[0.0], [2.0], [3.0], [4.0], [6.0]])
        y = np.array([[branin_1d(case)] for case in x])

        surrogate = KrigingSurrogate()
        surrogate.train(x, y)

        new_x = np.array([3.5])
        mu, sigma = surrogate.predict(new_x)

        assert_rel_error(self, mu, branin_1d(new_x), 1e-1)
        assert_rel_error(self, sigma, 0.07101449, 1e-2)
开发者ID:colinxs,项目名称:OpenMDAO,代码行数:14,代码来源:test_kriging.py

示例10: test_vector_input

# 需要导入模块: from openmdao.api import KrigingSurrogate [as 别名]
# 或者: from openmdao.api.KrigingSurrogate import predict [as 别名]
    def test_vector_input(self):
        surrogate = KrigingSurrogate(nugget=0.)

        x = np.array([[0., 0., 0.], [1., 1., 1.]])
        y = np.array([[0.], [3.]])

        surrogate.train(x, y)

        for x0, y0 in zip(x, y):
            mu, sigma = surrogate.predict(x0)
            assert_rel_error(self, mu, y0, 1e-9)
            assert_rel_error(self, sigma, 0, 1e-6)
开发者ID:colinxs,项目名称:OpenMDAO,代码行数:14,代码来源:test_kriging.py

示例11: test_vector_output

# 需要导入模块: from openmdao.api import KrigingSurrogate [as 别名]
# 或者: from openmdao.api.KrigingSurrogate import predict [as 别名]
    def test_vector_output(self):
        surrogate = KrigingSurrogate(nugget=0., eval_rmse=True)

        y = np.array([[0., 0.], [1., 1.], [2., 0.]])
        x = np.array([[0.], [2.], [4.]])

        surrogate.train(x, y)

        for x0, y0 in zip(x, y):
            mu, sigma = surrogate.predict(x0)
            assert_rel_error(self, mu, [y0], 1e-9)
            assert_rel_error(self, sigma, [[0, 0]], 1e-6)
开发者ID:OpenMDAO,项目名称:OpenMDAO,代码行数:14,代码来源:test_kriging.py


注:本文中的openmdao.api.KrigingSurrogate.predict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。