|
2 | 2 |
|
3 | 3 | ## Simple spotPython run |
4 | 4 |
|
5 | | -```python |
| 5 | +```{python} |
6 | 6 | import numpy as np |
7 | | -from math import inf |
8 | | -from spotPython.fun.objectivefunctions import analytical |
9 | 7 | from spotPython.spot import spot |
10 | | -# number of initial points: |
11 | | -ni = 7 |
12 | | -# number of points |
13 | | -n = 10 |
14 | | - |
15 | | -fun = analytical().fun_sphere |
16 | | -lower = np.array([-1]) |
17 | | -upper = np.array([1]) |
18 | | -design_control={"init_size": ni} |
19 | | - |
20 | | -spot_1 = spot.Spot(fun=fun, |
21 | | - lower = lower, |
22 | | - upper= upper, |
23 | | - fun_evals = n, |
24 | | - show_progress=True, |
25 | | - design_control=design_control,) |
26 | | -spot_1.run() |
| 8 | +from spotPython.fun.objectivefunctions import analytical |
| 9 | +from spotPython.utils.init import fun_control_init, design_control_init, surrogate_control_init |
| 10 | +
|
| 11 | +fun = analytical().fun_branin |
| 12 | +fun_control = fun_control_init(lower = np.array([-5, 0]), |
| 13 | + upper = np.array([10, 15]), |
| 14 | + fun_evals=20) |
| 15 | +design_control = design_control_init(init_size=10) |
| 16 | +surrogate_control = surrogate_control_init(n_theta=2) |
| 17 | +S = spot.Spot(fun=fun, fun_control=fun_control, design_control=design_control) |
| 18 | +S.run() |
| 19 | +``` |
| 20 | + |
| 21 | +```raw |
| 22 | +spotPython tuning: 3.146824136952164 [######----] 55.00% |
| 23 | +spotPython tuning: 3.146824136952164 [######----] 60.00% |
| 24 | +spotPython tuning: 3.146824136952164 [######----] 65.00% |
| 25 | +spotPython tuning: 3.146824136952164 [#######---] 70.00% |
| 26 | +spotPython tuning: 1.1487233101571483 [########--] 75.00% |
| 27 | +spotPython tuning: 1.0236891516766402 [########--] 80.00% |
| 28 | +spotPython tuning: 0.41994270072214057 [########--] 85.00% |
| 29 | +spotPython tuning: 0.40193544341108023 [#########-] 90.00% |
| 30 | +spotPython tuning: 0.3991519598268951 [##########] 95.00% |
| 31 | +spotPython tuning: 0.3991519598268951 [##########] 100.00% Done... |
27 | 32 | ``` |
28 | 33 |
|
| 34 | + |
| 35 | +```python |
| 36 | +S.print_results() |
| 37 | +``` |
| 38 | + |
| 39 | +```raw |
| 40 | +min y: 0.3991519598268951 |
| 41 | +x0: 3.1546575195040987 |
| 42 | +x1: 2.285931113926263 |
| 43 | +``` |
| 44 | + |
| 45 | + |
| 46 | +```{python} |
| 47 | +S.plot_progress(log_y=True) |
| 48 | +``` |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | +```{python} |
| 54 | +S.surrogate.plot() |
| 55 | +``` |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
29 | 60 | ## Further Examples |
30 | 61 |
|
31 | | -Examples can be found in the Hyperparameter Tuning Cookbook, e.g., [Documentation of the Sequential Parameter Optimization](https://sequential-parameter-optimization.github.io/Hyperparameter-Tuning-Cookbook/99_spot_doc.html). |
| 62 | +Examples can be found in the Hyperparameter Tuning Cookbook, e.g., [Documentation of the Sequential Parameter Optimization](https://sequential-parameter-optimization.github.io/Hyperparameter-Tuning-Cookbook/a_04_spot_doc.html). |
0 commit comments