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


Python Ishigami.evaluate方法代码示例

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


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

示例1: test_morris

# 需要导入模块: from SALib.test_functions import Ishigami [as 别名]
# 或者: from SALib.test_functions.Ishigami import evaluate [as 别名]
def test_morris():

    # Generate inputs
    cmd = "python {cli} sample morris -p {fn} -o model_input.txt -n 100\
    --precision=8 --levels=10 --seed=100 -lo False"\
    .format(cli=salib_cli, fn=ishigami_fp).split()

    subprocess.run(cmd)

    # Run model and save output
    np.savetxt('model_output.txt', Ishigami.evaluate(
        np.loadtxt('model_input.txt')))

    # run analysis
    analyze_cmd = "python {cli} analyze morris -p {fn} -X model_input.txt\
    -Y model_output.txt -c 0 -r 1000 -l 10 --seed=100"\
     .format(cli=salib_cli, fn=ishigami_fp).split()

    result = subprocess.check_output(analyze_cmd, universal_newlines=True)
    result = re.sub(r'[\n\t\s]*', '', result)

    expected_output = """ParameterMu_StarMuMu_Star_ConfSigmax13.3753.3750.5903.003x21.4740.1180.0001.477x32.6980.4200.5954.020"""

    assert len(result) > 0 and result == expected_output, \
        "Results did not match expected values:\n\n Expected: \n{} \n\n Got: \n{}".format(
            expected_output, result)
开发者ID:SALib,项目名称:SALib,代码行数:28,代码来源:test_cli_analyze.py

示例2: test_include_print

# 需要导入模块: from SALib.test_functions import Ishigami [as 别名]
# 或者: from SALib.test_functions.Ishigami import evaluate [as 别名]
def test_include_print():
    problem, param_values = setup_samples()
    Y = Ishigami.evaluate(param_values)
    sobol.analyze(problem, Y,
                  calc_second_order=True,
                  conf_level=0.95,
                  print_to_console=True)
开发者ID:SALib,项目名称:SALib,代码行数:9,代码来源:test_sobol.py

示例3: test_sobol_to_df

# 需要导入模块: from SALib.test_functions import Ishigami [as 别名]
# 或者: from SALib.test_functions.Ishigami import evaluate [as 别名]
def test_sobol_to_df():
    params = ['x1', 'x2', 'x3']
    problem = {
        'num_vars': 3,
        'names': params,
        'bounds': [[-np.pi, np.pi]]*3
    }

    X = saltelli.sample(problem, 1000)
    Y = Ishigami.evaluate(X)
    Si = sobol.analyze(problem, Y, print_to_console=False)
    total, first, second = Si.to_df()

    assert isinstance(total, pd.DataFrame), \
        "Total Si: Expected DataFrame, got {}".format(type(total))
    assert isinstance(first, pd.DataFrame), \
        "First Si: Expected DataFrame, got {}".format(type(first))
    assert isinstance(second, pd.DataFrame), \
        "Second Si: Expected DataFrame, got {}".format(type(second))

    expected_index = set(params)
    assert set(total.index) == expected_index, \
        "Index for Total Si are incorrect"
    assert set(first.index) == expected_index, \
        "Index for first order Si are incorrect"
    assert set(second.index) == set([('x1', 'x2'),
                                     ('x1', 'x3'),
                                     ('x2', 'x3')]), \
        "Index for second order Si are incorrect"
开发者ID:SALib,项目名称:SALib,代码行数:31,代码来源:test_to_df.py

示例4: test_regression_morris_groups_brute_optim

# 需要导入模块: from SALib.test_functions import Ishigami [as 别名]
# 或者: from SALib.test_functions.Ishigami import evaluate [as 别名]
    def test_regression_morris_groups_brute_optim(self, set_seed):

        set_seed
        param_file = 'src/SALib/test_functions/params/Ishigami_groups.txt'
        problem = read_param_file(param_file)

        param_values = sample(problem=problem, N=50,
                              num_levels=4,
                              optimal_trajectories=6,
                              local_optimization=False)

        Y = Ishigami.evaluate(param_values)

        Si = morris.analyze(problem, param_values, Y,
                            conf_level=0.95, print_to_console=False,
                            num_levels=4)

        assert_allclose(Si['mu'], [9.786986, np.NaN],
                        atol=0, rtol=1e-5)

        assert_allclose(Si['sigma'], [6.453729, np.NaN],
                        atol=0, rtol=1e-5)

        assert_allclose(Si['mu_star'], [9.786986, 7.875],
                        atol=0, rtol=1e-5)
开发者ID:SALib,项目名称:SALib,代码行数:27,代码来源:test_regression.py

示例5: test_fast_to_df

# 需要导入模块: from SALib.test_functions import Ishigami [as 别名]
# 或者: from SALib.test_functions.Ishigami import evaluate [as 别名]
def test_fast_to_df():
    params = ['x1', 'x2', 'x3']
    problem = {
        'num_vars': 3,
        'names': params,
        'groups': None,
        'bounds': [[-3.14159265359, 3.14159265359],
                   [-3.14159265359, 3.14159265359],
                   [-3.14159265359, 3.14159265359]]
    }

    param_values = fast_sampler.sample(problem, 1000)
    Y = Ishigami.evaluate(param_values)

    Si = fast.analyze(problem, Y, print_to_console=False)
    Si_df = Si.to_df()

    expected_index = set(params)
    assert isinstance(Si_df, pd.DataFrame), \
        "FAST Si: Expected DataFrame, got {}".format(type(Si_df))
    assert set(Si_df.index) == expected_index, "Incorrect index in DataFrame"

    col_names = set(['S1', 'ST'])
    assert set(Si_df.columns) == col_names, \
        "Unexpected column names in DataFrame. Expected {}, got {}".format(
            col_names, Si_df.columns)
开发者ID:SALib,项目名称:SALib,代码行数:28,代码来源:test_to_df.py

示例6: test_regression_morris_optimal

# 需要导入模块: from SALib.test_functions import Ishigami [as 别名]
# 或者: from SALib.test_functions.Ishigami import evaluate [as 别名]
    def test_regression_morris_optimal(self, set_seed):
        '''
        Tests the use of optimal trajectories with Morris.

        Uses brute force approach

        Note that the relative tolerance is set to a very high value
        (default is 1e-05) due to the coarse nature of the num_levels.
        '''
        set_seed
        param_file = 'src/SALib/test_functions/params/Ishigami.txt'
        problem = read_param_file(param_file)
        param_values = sample(problem=problem, N=20,
                              num_levels=4,
                              optimal_trajectories=9,
                              local_optimization=True)

        Y = Ishigami.evaluate(param_values)

        Si = morris.analyze(problem, param_values, Y,
                            conf_level=0.95, print_to_console=False,
                            num_levels=4)

        assert_allclose(Si['mu_star'],
                        [9.786986e+00, 7.875000e+00, 1.388621],
                        atol=0,
                        rtol=1e-5)
开发者ID:SALib,项目名称:SALib,代码行数:29,代码来源:test_regression.py

示例7: test_bad_conf_level

# 需要导入模块: from SALib.test_functions import Ishigami [as 别名]
# 或者: from SALib.test_functions.Ishigami import evaluate [as 别名]
def test_bad_conf_level():
    problem, param_values = setup_samples()
    Y = Ishigami.evaluate(param_values)
    with raises(RuntimeError):
        sobol.analyze(problem, Y,
                      calc_second_order=True,
                      conf_level=1.01,
                      print_to_console=False)
开发者ID:SALib,项目名称:SALib,代码行数:10,代码来源:test_sobol.py

示例8: test_regression_rbd_fast

# 需要导入模块: from SALib.test_functions import Ishigami [as 别名]
# 或者: from SALib.test_functions.Ishigami import evaluate [as 别名]
def test_regression_rbd_fast():
    param_file = 'src/SALib/test_functions/params/Ishigami.txt'
    problem = read_param_file(param_file)
    param_values = latin.sample(problem, 10000)

    Y = Ishigami.evaluate(param_values)

    Si = rbd_fast.analyze(problem, param_values, Y, print_to_console=False)
    assert_allclose(Si['S1'], [0.31, 0.44, 0.00], atol=5e-2, rtol=1e-1)
开发者ID:SALib,项目名称:SALib,代码行数:11,代码来源:test_regression.py

示例9: test_regression_dgsm

# 需要导入模块: from SALib.test_functions import Ishigami [as 别名]
# 或者: from SALib.test_functions.Ishigami import evaluate [as 别名]
def test_regression_dgsm():
    param_file = 'src/SALib/test_functions/params/Ishigami.txt'
    problem = read_param_file(param_file)
    param_values = finite_diff.sample(problem, 10000, delta=0.001)

    Y = Ishigami.evaluate(param_values)

    Si = dgsm.analyze(problem, param_values, Y,
                      conf_level=0.95, print_to_console=False)

    assert_allclose(Si['dgsm'], [2.229, 7.066, 3.180], atol=5e-2, rtol=1e-1)
开发者ID:SALib,项目名称:SALib,代码行数:13,代码来源:test_regression.py

示例10: test_regression_delta

# 需要导入模块: from SALib.test_functions import Ishigami [as 别名]
# 或者: from SALib.test_functions.Ishigami import evaluate [as 别名]
def test_regression_delta():
    param_file = 'src/SALib/test_functions/params/Ishigami.txt'
    problem = read_param_file(param_file)
    param_values = latin.sample(problem, 10000)

    Y = Ishigami.evaluate(param_values)

    Si = delta.analyze(problem, param_values, Y, num_resamples=10,
                       conf_level=0.95, print_to_console=True)

    assert_allclose(Si['delta'], [0.210, 0.358, 0.155], atol=5e-2, rtol=1e-1)
    assert_allclose(Si['S1'], [0.31, 0.44, 0.00], atol=5e-2, rtol=1e-1)
开发者ID:SALib,项目名称:SALib,代码行数:14,代码来源:test_regression.py

示例11: test_regression_sobol_parallel

# 需要导入模块: from SALib.test_functions import Ishigami [as 别名]
# 或者: from SALib.test_functions.Ishigami import evaluate [as 别名]
def test_regression_sobol_parallel():
    param_file = 'src/SALib/test_functions/params/Ishigami.txt'
    problem = read_param_file(param_file)
    param_values = saltelli.sample(problem, 10000, calc_second_order=True)

    Y = Ishigami.evaluate(param_values)

    Si = sobol.analyze(problem, Y,
                       calc_second_order=True, parallel=True,
                       conf_level=0.95, print_to_console=False)

    assert_allclose(Si['S1'], [0.31, 0.44, 0.00], atol=5e-2, rtol=1e-1)
    assert_allclose(Si['ST'], [0.55, 0.44, 0.24], atol=5e-2, rtol=1e-1)
    assert_allclose([Si['S2'][0][1], Si['S2'][0][2], Si['S2'][1][2]], [
                    0.00, 0.25, 0.00], atol=5e-2, rtol=1e-1)
开发者ID:SALib,项目名称:SALib,代码行数:17,代码来源:test_regression.py

示例12: test_regression_morris_groups

# 需要导入模块: from SALib.test_functions import Ishigami [as 别名]
# 或者: from SALib.test_functions.Ishigami import evaluate [as 别名]
    def test_regression_morris_groups(self, set_seed):
        set_seed
        param_file = 'src/SALib/test_functions/params/Ishigami_groups.txt'
        problem = read_param_file(param_file)

        param_values = sample(problem=problem, N=10000,
                              num_levels=4,
                              optimal_trajectories=None)

        Y = Ishigami.evaluate(param_values)

        Si = morris.analyze(problem, param_values, Y,
                            conf_level=0.95, print_to_console=False,
                            num_levels=4)

        assert_allclose(Si['mu_star'], [7.610322, 10.197014],
                        atol=0, rtol=1e-5)
开发者ID:SALib,项目名称:SALib,代码行数:19,代码来源:test_regression.py

示例13: test_regression_sobol_groups

# 需要导入模块: from SALib.test_functions import Ishigami [as 别名]
# 或者: from SALib.test_functions.Ishigami import evaluate [as 别名]
def test_regression_sobol_groups():
    problem = {
        'num_vars': 3,
        'names': ['x1', 'x2', 'x3'],
        'bounds': [[-np.pi, np.pi]] * 3,
        'groups': ['G1', 'G2', 'G1']
    }
    param_values = saltelli.sample(problem, 10000, calc_second_order=True)

    Y = Ishigami.evaluate(param_values)
    Si = sobol.analyze(problem, Y,
                       calc_second_order=True, parallel=True,
                       conf_level=0.95, print_to_console=False)

    assert_allclose(Si['S1'], [0.55, 0.44], atol=5e-2, rtol=1e-1)
    assert_allclose(Si['ST'], [0.55, 0.44], atol=5e-2, rtol=1e-1)
    assert_allclose(Si['S2'][0][1], [0.00], atol=5e-2, rtol=1e-1)
开发者ID:SALib,项目名称:SALib,代码行数:19,代码来源:test_regression.py

示例14: test_regression_morris_vanilla

# 需要导入模块: from SALib.test_functions import Ishigami [as 别名]
# 或者: from SALib.test_functions.Ishigami import evaluate [as 别名]
    def test_regression_morris_vanilla(self, set_seed):
        """Note that this is a poor estimate of the Ishigami
        function.
        """
        set_seed
        param_file = 'src/SALib/test_functions/params/Ishigami.txt'
        problem = read_param_file(param_file)
        param_values = sample(problem, 10000, 4,
                              optimal_trajectories=None)

        Y = Ishigami.evaluate(param_values)

        Si = morris.analyze(problem, param_values, Y,
                            conf_level=0.95, print_to_console=False,
                            num_levels=4)

        assert_allclose(Si['mu_star'], [7.536586, 7.875, 6.308785],
                        atol=0, rtol=1e-5)
开发者ID:SALib,项目名称:SALib,代码行数:20,代码来源:test_regression.py

示例15: test_parallel_first_order

# 需要导入模块: from SALib.test_functions import Ishigami [as 别名]
# 或者: from SALib.test_functions.Ishigami import evaluate [as 别名]
def test_parallel_first_order():
    c2o = False
    N = 10000
    problem,param_values = setup_samples(N=N, calc_second_order=c2o)
    Y = Ishigami.evaluate(param_values)

    A,B,AB,BA = sobol.separate_output_values(Y, D=3, N=N,
                                            calc_second_order=c2o)
    r = np.random.randint(N, size=(N, 100))
    Z = norm.ppf(0.5 + 0.95 / 2)
    tasks, n_processors = sobol.create_task_list(D=3,
                            calc_second_order=c2o, n_processors=None)
    Si_list = []
    for t in tasks:
        Si_list.append(sobol.sobol_parallel(Z, A, AB, BA, B, r, t))
    Si = sobol.Si_list_to_dict(Si_list, D=3, calc_second_order=c2o)

    assert_allclose(Si['S1'], [0.31, 0.44, 0.00], atol=5e-2, rtol=1e-1)
    assert_allclose(Si['ST'], [0.55, 0.44, 0.24], atol=5e-2, rtol=1e-1)
开发者ID:cmutel,项目名称:SALib,代码行数:21,代码来源:test_sobol.py


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