| @@ 49-68 (lines=20) @@ | ||
| 46 | assert hyper.best_para(objective_function)["x1"] in search_space["x1"] |
|
| 47 | ||
| 48 | ||
| 49 | def test_search_space_2(): |
|
| 50 | def objective_function(opt): |
|
| 51 | score = -opt["x1"] * opt["x1"] |
|
| 52 | return score |
|
| 53 | ||
| 54 | search_space = { |
|
| 55 | "x1": list(range(0, 100, 1)), |
|
| 56 | "str1": ["0", "1", "2"], |
|
| 57 | } |
|
| 58 | ||
| 59 | hyper = Hyperactive() |
|
| 60 | hyper.add_search( |
|
| 61 | objective_function, |
|
| 62 | search_space, |
|
| 63 | n_iter=15, |
|
| 64 | ) |
|
| 65 | hyper.run() |
|
| 66 | ||
| 67 | assert isinstance(hyper.search_data(objective_function), pd.DataFrame) |
|
| 68 | assert hyper.best_para(objective_function)["str1"] in search_space["str1"] |
|
| 69 | ||
| 70 | ||
| 71 | def test_search_space_3(): |
|
| @@ 28-46 (lines=19) @@ | ||
| 25 | assert hyper.best_para(objective_function)["x1"] in search_space["x1"] |
|
| 26 | ||
| 27 | ||
| 28 | def test_search_space_1(): |
|
| 29 | def objective_function(opt): |
|
| 30 | score = -opt["x1"] * opt["x1"] |
|
| 31 | return score |
|
| 32 | ||
| 33 | search_space = { |
|
| 34 | "x1": list(np.arange(0, 0.003, 0.001)), |
|
| 35 | } |
|
| 36 | ||
| 37 | hyper = Hyperactive() |
|
| 38 | hyper.add_search( |
|
| 39 | objective_function, |
|
| 40 | search_space, |
|
| 41 | n_iter=15, |
|
| 42 | ) |
|
| 43 | hyper.run() |
|
| 44 | ||
| 45 | assert isinstance(hyper.search_data(objective_function), pd.DataFrame) |
|
| 46 | assert hyper.best_para(objective_function)["x1"] in search_space["x1"] |
|
| 47 | ||
| 48 | ||
| 49 | def test_search_space_2(): |
|
| @@ 7-25 (lines=19) @@ | ||
| 4 | from hyperactive import Hyperactive |
|
| 5 | ||
| 6 | ||
| 7 | def test_search_space_0(): |
|
| 8 | def objective_function(opt): |
|
| 9 | score = -opt["x1"] * opt["x1"] |
|
| 10 | return score |
|
| 11 | ||
| 12 | search_space = { |
|
| 13 | "x1": list(range(0, 3, 1)), |
|
| 14 | } |
|
| 15 | ||
| 16 | hyper = Hyperactive() |
|
| 17 | hyper.add_search( |
|
| 18 | objective_function, |
|
| 19 | search_space, |
|
| 20 | n_iter=15, |
|
| 21 | ) |
|
| 22 | hyper.run() |
|
| 23 | ||
| 24 | assert isinstance(hyper.search_data(objective_function), pd.DataFrame) |
|
| 25 | assert hyper.best_para(objective_function)["x1"] in search_space["x1"] |
|
| 26 | ||
| 27 | ||
| 28 | def test_search_space_1(): |
|