當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。