import warnings
warnings.filterwarnings("ignore")
import numpy as np
from spotpython.fun.objectivefunctions import Analytical
from spotpython.spot import Spot
from spotpython.utils.init import fun_control_init, design_control_init, surrogate_control_init25 Benchmarking SPOT Kriging with Matern Kernel on 6D Rosenbrock Function and 10D Michalewicz Function
25.1 SPOT Kriging in 6 Dimensions: Rosenbrock Function
This notebook demonstrates how to use the Spot class from spotpython for Kriging surrogates on the 6-dimensional Rosenbrock function. We use a maximum of 100 function evaluations.
To visualize the optimization process, you can start tensorboard with:
tensorboard --logdir="runs/"25.1.1 Define the 6D Rosenbrock Function
dim = 6
lower = np.full(dim, -2)
upper = np.full(dim, 2)
fun = Analytical().fun_rosenbrock
fun_evals = 10025.1.2 Set up SPOT Controls
init_size = dim
seed = 321
max_surrogate_points = fun_evals
max_time = 6025.1.3 Compile the necessary imports
fun_control = fun_control_init(
lower=lower,
upper=upper,
fun_evals=fun_evals,
seed=seed,
show_progress=True,
TENSORBOARD_CLEAN=True,
tensorboard_log=True,
max_time=max_time
)
design_control = design_control_init(init_size=init_size)
surrogate_control_exact = surrogate_control_init(max_surrogate_points=max_surrogate_points)Moving TENSORBOARD_PATH: runs/ to TENSORBOARD_PATH_OLD: runs_OLD/runs_2025_11_05_16_01_14_0
Created spot_tensorboard_path: runs/spot_logs/000_p040025_2025-11-05_16-01-14 for SummaryWriter()
25.1.4 Sklearn Gaussian Process Regressor as Surrogate
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import Matern, ConstantKernel
# Used a Matern kernel instead of the standard spotpython RBF kernel
kernel = ConstantKernel(1.0, (1e-2, 1e12)) * Matern(length_scale=1.0, length_scale_bounds=(1e-4, 1e2), nu=2.5)
S_GP = GaussianProcessRegressor(kernel=kernel, n_restarts_optimizer=100)
S_rosen = Spot(
fun=fun,
fun_control=fun_control,
design_control=design_control,
surrogate_control=surrogate_control_exact,
surrogate=S_GP,
)
S_rosen.run()spotpython tuning: 321.8341532536645 [#---------] 7.00%. Success rate: 0.00%
spotpython tuning: 321.8341532536645 [#---------] 8.00%. Success rate: 0.00%
spotpython tuning: 321.8341532536645 [#---------] 9.00%. Success rate: 0.00%
spotpython tuning: 179.35533825140524 [#---------] 10.00%. Success rate: 25.00%
spotpython tuning: 147.21603987143845 [#---------] 11.00%. Success rate: 40.00%
spotpython tuning: 126.87473490284455 [#---------] 12.00%. Success rate: 50.00%
spotpython tuning: 106.90954193892807 [#---------] 13.00%. Success rate: 57.14%
spotpython tuning: 77.69348083271842 [#---------] 14.00%. Success rate: 62.50%
spotpython tuning: 67.649153095507 [##--------] 15.00%. Success rate: 66.67%
spotpython tuning: 67.649153095507 [##--------] 16.00%. Success rate: 60.00%
spotpython tuning: 66.9626271912866 [##--------] 17.00%. Success rate: 63.64%
spotpython tuning: 66.88621978082725 [##--------] 18.00%. Success rate: 66.67%
spotpython tuning: 63.391023128695885 [##--------] 19.00%. Success rate: 69.23%
spotpython tuning: 53.85636814729686 [##--------] 20.00%. Success rate: 71.43%
spotpython tuning: 53.49391616057949 [##--------] 21.00%. Success rate: 73.33%
spotpython tuning: 52.75720177494789 [##--------] 22.00%. Success rate: 75.00%
spotpython tuning: 51.70260384929565 [##--------] 23.00%. Success rate: 76.47%
spotpython tuning: 48.25120609312787 [##--------] 24.00%. Success rate: 77.78%
spotpython tuning: 48.25120609312787 [##--------] 25.00%. Success rate: 73.68%
spotpython tuning: 48.25120609312787 [###-------] 26.00%. Success rate: 70.00%
spotpython tuning: 46.3246537911565 [###-------] 27.00%. Success rate: 71.43%
spotpython tuning: 42.76481779596959 [###-------] 28.00%. Success rate: 72.73%
spotpython tuning: 42.76481779596959 [###-------] 29.00%. Success rate: 69.57%
spotpython tuning: 41.526528813290554 [###-------] 30.00%. Success rate: 70.83%
spotpython tuning: 40.952097655681094 [###-------] 31.00%. Success rate: 72.00%
spotpython tuning: 40.934901028622136 [###-------] 32.00%. Success rate: 73.08%
spotpython tuning: 40.22233309635489 [###-------] 33.00%. Success rate: 74.07%
spotpython tuning: 38.03909149661601 [###-------] 34.00%. Success rate: 75.00%
spotpython tuning: 38.03909149661601 [####------] 35.00%. Success rate: 72.41%
spotpython tuning: 37.39451854311546 [####------] 36.00%. Success rate: 73.33%
spotpython tuning: 36.59330281483051 [####------] 37.00%. Success rate: 74.19%
spotpython tuning: 33.78842007466847 [####------] 38.00%. Success rate: 75.00%
spotpython tuning: 29.317922160603857 [####------] 39.00%. Success rate: 75.76%
spotpython tuning: 26.94321102808712 [####------] 40.00%. Success rate: 76.47%
spotpython tuning: 22.848920108947098 [####------] 41.00%. Success rate: 77.14%
spotpython tuning: 20.07864694133197 [####------] 42.00%. Success rate: 77.78%
spotpython tuning: 19.58344025675232 [####------] 43.00%. Success rate: 78.38%
spotpython tuning: 19.195698477520416 [####------] 44.00%. Success rate: 78.95%
spotpython tuning: 18.41162093501518 [####------] 45.00%. Success rate: 79.49%
spotpython tuning: 18.41162093501518 [#####-----] 46.00%. Success rate: 77.50%
spotpython tuning: 17.04396783149541 [#####-----] 47.00%. Success rate: 78.05%
spotpython tuning: 17.04396783149541 [#####-----] 48.00%. Success rate: 76.19%
spotpython tuning: 17.04396783149541 [#####-----] 49.00%. Success rate: 74.42%
spotpython tuning: 16.716918611083482 [#####-----] 50.00%. Success rate: 75.00%
spotpython tuning: 15.685328757334153 [#####-----] 51.00%. Success rate: 75.56%
spotpython tuning: 10.728656399777483 [#####-----] 52.00%. Success rate: 76.09%
spotpython tuning: 10.708613438035691 [#####-----] 53.00%. Success rate: 76.60%
spotpython tuning: 9.493175015108505 [#####-----] 54.00%. Success rate: 77.08%
spotpython tuning: 8.984673581295642 [######----] 55.00%. Success rate: 77.55%
spotpython tuning: 8.909168454357982 [######----] 56.00%. Success rate: 78.00%
spotpython tuning: 8.646443932174709 [######----] 57.00%. Success rate: 78.43%
spotpython tuning: 8.201566673391527 [######----] 58.00%. Success rate: 78.85%
spotpython tuning: 8.0747498879791 [######----] 59.00%. Success rate: 79.25%
spotpython tuning: 7.199393834174794 [######----] 60.00%. Success rate: 79.63%
spotpython tuning: 7.199393834174794 [######----] 61.00%. Success rate: 78.18%
spotpython tuning: 7.096065922351175 [######----] 62.00%. Success rate: 78.57%
spotpython tuning: 7.045044277086247 [######----] 63.00%. Success rate: 78.95%
spotpython tuning: 7.045044277086247 [######----] 64.00%. Success rate: 77.59%
spotpython tuning: 6.681884006985997 [######----] 65.00%. Success rate: 77.97%
spotpython tuning: 6.681884006985997 [#######---] 66.00%. Success rate: 76.67%
spotpython tuning: 6.429870707309329 [#######---] 67.00%. Success rate: 77.05%
spotpython tuning: 6.301561599116909 [#######---] 68.00%. Success rate: 77.42%
spotpython tuning: 5.946169600644429 [#######---] 69.00%. Success rate: 77.78%
spotpython tuning: 5.756546554580202 [#######---] 70.00%. Success rate: 78.12%
spotpython tuning: 5.691561891034147 [#######---] 71.00%. Success rate: 78.46%
spotpython tuning: 5.691561891034147 [#######---] 72.00%. Success rate: 77.27%
spotpython tuning: 5.64907495593322 [#######---] 73.00%. Success rate: 77.61%
spotpython tuning: 5.550706231223277 [#######---] 74.00%. Success rate: 77.94%
spotpython tuning: 5.252881183682973 [########--] 75.00%. Success rate: 78.26%
spotpython tuning: 4.9427121023600575 [########--] 76.00%. Success rate: 78.57%
spotpython tuning: 4.9427121023600575 [########--] 77.00%. Success rate: 77.46%
spotpython tuning: 4.9427121023600575 [########--] 78.00%. Success rate: 76.39%
spotpython tuning: 4.910436037497828 [########--] 79.00%. Success rate: 76.71%
spotpython tuning: 4.814354750771902 [########--] 80.00%. Success rate: 77.03%
spotpython tuning: 4.658936650250243 [########--] 81.00%. Success rate: 77.33%
spotpython tuning: 4.657201834651251 [########--] 82.00%. Success rate: 77.63%
spotpython tuning: 4.638700962054523 [########--] 83.00%. Success rate: 77.92%
spotpython tuning: 4.638066081295671 [########--] 84.00%. Success rate: 78.21%
spotpython tuning: 4.616289811439322 [########--] 85.00%. Success rate: 78.48%
spotpython tuning: 4.593300859449407 [#########-] 86.00%. Success rate: 78.75%
spotpython tuning: 4.527871531778343 [#########-] 87.00%. Success rate: 79.01%
spotpython tuning: 4.424009347350707 [#########-] 88.00%. Success rate: 79.27%
spotpython tuning: 4.368626868105252 [#########-] 89.00%. Success rate: 79.52%
spotpython tuning: 4.301279272009175 [#########-] 90.00%. Success rate: 79.76%
spotpython tuning: 4.270775181092241 [#########-] 91.00%. Success rate: 80.00%
spotpython tuning: 4.245045896945404 [#########-] 92.00%. Success rate: 80.23%
spotpython tuning: 4.230255601587355 [#########-] 93.00%. Success rate: 80.46%
spotpython tuning: 4.230255601587355 [#########-] 94.00%. Success rate: 79.55%
spotpython tuning: 4.194642949778596 [##########] 95.00%. Success rate: 79.78%
spotpython tuning: 4.10911526153011 [##########] 96.00%. Success rate: 80.00%
spotpython tuning: 4.079815859995404 [##########] 97.00%. Success rate: 80.22%
spotpython tuning: 4.061412243245732 [##########] 98.00%. Success rate: 80.43%
spotpython tuning: 4.061412243245732 [##########] 99.00%. Success rate: 79.57%
spotpython tuning: 4.061412243245732 [##########] 100.00%. Success rate: 78.72% Done...
Experiment saved to 000_res.pkl
<spotpython.spot.spot.Spot at 0x325c97230>
S_rosen.plot_progress(log_y=True, title="Exact sklearn Kriging Progress with y")
print(f"[6D] Exact Kriging y: min y = {S_rosen.min_y:.4f} at x = {S_rosen.min_X}")[6D] Exact Kriging y: min y = 4.0614 at x = [0.39273266 0.16267094 0.01329175 0.00191027 0.01602282 0.00583742]
Plot of the surrogate model in the first two dimensions:
from spotpython.plot.contour import plotModel
model = S_rosen.surrogate
fig, axes = plotModel(
model=model,
lower=lower,
upper=upper,
i=0,
j=1,
n_grid=100,
contour_levels=20,
)
25.1.5 Evaluation of 30 repeats with Kriging and Matern kernel
Since 30 repeats were performed and stored in spot_rosen.json, we can now evaluate the results:
import json
import numpy as np
# Load results from spot_rosen.json
with open("spot_rosen.json", "r") as f:
data = json.load(f)
# Extract all "evaluations" values
evals = [
iteration["sampled_locations"][0]["evaluations"]
for iteration in data["search_iterations"]
]
# Compute mean and standard deviation
mean_eval = np.mean(evals)
std_eval = np.std(evals)
print(f"Mean of evaluations: {mean_eval:.6f}")
print(f"Standard deviation of evaluations: {std_eval:.6f}")Mean of evaluations: 3.015181
Standard deviation of evaluations: 1.901997
25.2 SPOT Kriging in 10 Dimensions: Exact (Michalewicz Function)
This notebook demonstrates how to use the Spot class from spotpython for Kriging surrogates on the 10-dimensional Michalewicz function. We use a maximum of 300 function evaluations.
Start tensorboard with:
tensorboard --logdir="runs/"import warnings
warnings.filterwarnings("ignore")
import numpy as np
from spotpython.fun.objectivefunctions import Analytical
from spotpython.spot import Spot
from spotpython.utils.init import fun_control_init, design_control_init, surrogate_control_init25.2.1 Define the 10D Michalewicz Function
dim = 10
lower = np.full(dim, 0)
upper = np.full(dim, np.pi)
fun = Analytical().fun_michalewicz
fun_evals = 300
max_time = 6025.2.2 Set up SPOT Controls
init_size = dim
seed = 321
max_surrogate_points = fun_evals
max_time = 6025.2.3 Compile the necessary imports
fun_control = fun_control_init(
lower=lower,
upper=upper,
fun_evals=fun_evals,
seed=seed,
show_progress=True,
TENSORBOARD_CLEAN=True,
tensorboard_log=True,
max_time=max_time
)
design_control = design_control_init(init_size=init_size)
surrogate_control_exact = surrogate_control_init(max_surrogate_points=max_surrogate_points)Moving TENSORBOARD_PATH: runs/ to TENSORBOARD_PATH_OLD: runs_OLD/runs_2025_11_05_16_02_28_0
Created spot_tensorboard_path: runs/spot_logs/000_p040025_2025-11-05_16-02-28 for SummaryWriter()
25.2.4 Sklearn Gaussian Process Regressor as Surrogate
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import Matern, ConstantKernel
# Used a Matern kernel instead of the standard spotpython RBF kernel
kernel = ConstantKernel(1.0, (1e-2, 1e12)) * Matern(length_scale=1.0, length_scale_bounds=(1e-4, 1e2), nu=2.5)
S_GP = GaussianProcessRegressor(kernel=kernel, n_restarts_optimizer=100)
S_micha = Spot(
fun=fun,
fun_control=fun_control,
design_control=design_control,
surrogate_control=surrogate_control_exact,
surrogate=S_GP,
)
S_micha.run()spotpython tuning: -1.909128962635467 [----------] 3.67%. Success rate: 0.00%
spotpython tuning: -2.779427569120735 [----------] 4.00%. Success rate: 50.00%
spotpython tuning: -2.779427569120735 [----------] 4.33%. Success rate: 33.33%
spotpython tuning: -2.779427569120735 [----------] 4.67%. Success rate: 25.00%
spotpython tuning: -3.2119020715657354 [----------] 5.00%. Success rate: 40.00%
spotpython tuning: -3.2119020715657354 [#---------] 5.33%. Success rate: 33.33%
spotpython tuning: -3.2119020715657354 [#---------] 5.67%. Success rate: 28.57%
spotpython tuning: -3.3391515283456545 [#---------] 6.00%. Success rate: 37.50%
spotpython tuning: -3.3391515283456545 [#---------] 6.33%. Success rate: 33.33%
spotpython tuning: -3.411784183887579 [#---------] 6.67%. Success rate: 40.00%
spotpython tuning: -3.4470012631092235 [#---------] 7.00%. Success rate: 45.45%
spotpython tuning: -3.452659777394402 [#---------] 7.33%. Success rate: 50.00%
spotpython tuning: -3.5241383868272567 [#---------] 7.67%. Success rate: 53.85%
spotpython tuning: -3.5241383868272567 [#---------] 8.00%. Success rate: 50.00%
spotpython tuning: -3.5241383868272567 [#---------] 8.33%. Success rate: 46.67%
spotpython tuning: -3.5241383868272567 [#---------] 8.67%. Success rate: 43.75%
spotpython tuning: -3.539668108921282 [#---------] 9.00%. Success rate: 47.06%
spotpython tuning: -3.539668108921282 [#---------] 9.33%. Success rate: 44.44%
spotpython tuning: -3.592378171035613 [#---------] 9.67%. Success rate: 47.37%
spotpython tuning: -3.700837102694352 [#---------] 10.00%. Success rate: 50.00%
spotpython tuning: -3.7153829121872306 [#---------] 10.33%. Success rate: 52.38%
spotpython tuning: -3.7153829121872306 [#---------] 10.67%. Success rate: 50.00%
spotpython tuning: -3.7600786528206087 [#---------] 11.00%. Success rate: 52.17%
spotpython tuning: -3.7600786528206087 [#---------] 11.33%. Success rate: 50.00%
spotpython tuning: -3.914205440611785 [#---------] 11.67%. Success rate: 52.00%
spotpython tuning: -3.914205440611785 [#---------] 12.00%. Success rate: 50.00%
spotpython tuning: -3.914205440611785 [#---------] 12.33%. Success rate: 48.15%
spotpython tuning: -3.914205440611785 [#---------] 12.67%. Success rate: 46.43%
spotpython tuning: -3.914205440611785 [#---------] 13.00%. Success rate: 44.83%
spotpython tuning: -3.914205440611785 [#---------] 13.33%. Success rate: 43.33%
spotpython tuning: -3.914205440611785 [#---------] 13.67%. Success rate: 41.94%
spotpython tuning: -3.914205440611785 [#---------] 14.00%. Success rate: 40.62%
spotpython tuning: -3.914205440611785 [#---------] 14.33%. Success rate: 39.39%
spotpython tuning: -3.9188656932973576 [#---------] 14.67%. Success rate: 41.18%
spotpython tuning: -3.9188656932973576 [##--------] 15.00%. Success rate: 40.00%
spotpython tuning: -3.9367212624577723 [##--------] 15.33%. Success rate: 41.67%
spotpython tuning: -3.9367212624577723 [##--------] 15.67%. Success rate: 40.54%
spotpython tuning: -3.9367212624577723 [##--------] 16.00%. Success rate: 39.47%
spotpython tuning: -3.9367212624577723 [##--------] 16.33%. Success rate: 38.46%
spotpython tuning: -3.9802671655732884 [##--------] 16.67%. Success rate: 40.00%
spotpython tuning: -3.9802671655732884 [##--------] 17.00%. Success rate: 39.02%
spotpython tuning: -4.022920472359562 [##--------] 17.33%. Success rate: 40.48%
spotpython tuning: -4.059432782194066 [##--------] 17.67%. Success rate: 41.86%
spotpython tuning: -4.071845050102503 [##--------] 18.00%. Success rate: 43.18%
spotpython tuning: -4.184250662067885 [##--------] 18.33%. Success rate: 44.44%
spotpython tuning: -4.184250662067885 [##--------] 18.67%. Success rate: 43.48%
spotpython tuning: -4.184250662067885 [##--------] 19.00%. Success rate: 42.55%
spotpython tuning: -4.6931559719812235 [##--------] 19.33%. Success rate: 43.75%
spotpython tuning: -4.6931559719812235 [##--------] 19.67%. Success rate: 42.86%
spotpython tuning: -4.6931559719812235 [##--------] 20.00%. Success rate: 42.00%
spotpython tuning: -4.6931559719812235 [##--------] 20.33%. Success rate: 41.18%
spotpython tuning: -4.6931559719812235 [##--------] 20.67%. Success rate: 40.38%
spotpython tuning: -4.703441813321496 [##--------] 21.00%. Success rate: 41.51%
spotpython tuning: -4.843862293208037 [##--------] 21.33%. Success rate: 42.59%
spotpython tuning: -4.845078484269357 [##--------] 21.67%. Success rate: 43.64%
spotpython tuning: -4.85204666327521 [##--------] 22.00%. Success rate: 44.64%
spotpython tuning: -4.85204666327521 [##--------] 22.33%. Success rate: 43.86%
spotpython tuning: -4.85204666327521 [##--------] 22.67%. Success rate: 43.10%
spotpython tuning: -4.876573886972119 [##--------] 23.00%. Success rate: 44.07%
spotpython tuning: -4.877808067106256 [##--------] 23.33%. Success rate: 45.00%
spotpython tuning: -4.896220343118236 [##--------] 23.67%. Success rate: 45.90%
spotpython tuning: -4.896220343118236 [##--------] 24.00%. Success rate: 45.16%
spotpython tuning: -4.896220343118236 [##--------] 24.33%. Success rate: 44.44%
spotpython tuning: -5.037615777961309 [##--------] 24.67%. Success rate: 45.31%
spotpython tuning: -5.047558179566326 [##--------] 25.00%. Success rate: 46.15%
spotpython tuning: -5.047558179566326 [###-------] 25.33%. Success rate: 45.45%
spotpython tuning: -5.1129538418661085 [###-------] 25.67%. Success rate: 46.27%
spotpython tuning: -5.346490169085451 [###-------] 26.00%. Success rate: 47.06%
spotpython tuning: -5.346490169085451 [###-------] 26.33%. Success rate: 46.38%
spotpython tuning: -5.346490169085451 [###-------] 26.67%. Success rate: 45.71%
spotpython tuning: -5.346490169085451 [###-------] 27.00%. Success rate: 45.07%
spotpython tuning: -5.346490169085451 [###-------] 27.33%. Success rate: 44.44%
spotpython tuning: -5.346490169085451 [###-------] 27.67%. Success rate: 43.84%
spotpython tuning: -5.346490169085451 [###-------] 28.00%. Success rate: 43.24%
spotpython tuning: -5.346490169085451 [###-------] 28.33%. Success rate: 42.67%
spotpython tuning: -5.477490625764864 [###-------] 28.67%. Success rate: 43.42%
spotpython tuning: -5.477490625764864 [###-------] 29.00%. Success rate: 42.86%
spotpython tuning: -5.477490625764864 [###-------] 29.33%. Success rate: 42.31%
spotpython tuning: -5.514368850487695 [###-------] 29.67%. Success rate: 43.04%
spotpython tuning: -5.515288408974795 [###-------] 30.00%. Success rate: 43.75%
spotpython tuning: -5.551479388709216 [###-------] 30.33%. Success rate: 44.44%
spotpython tuning: -5.564748646397428 [###-------] 30.67%. Success rate: 45.12%
spotpython tuning: -5.77816968424698 [###-------] 31.00%. Success rate: 45.78%
spotpython tuning: -6.017273737802407 [###-------] 31.33%. Success rate: 46.43%
spotpython tuning: -6.241783691816167 [###-------] 31.67%. Success rate: 47.06%
spotpython tuning: -6.257203610763855 [###-------] 32.00%. Success rate: 47.67%
spotpython tuning: -6.257203610763855 [###-------] 32.33%. Success rate: 47.13%
spotpython tuning: -6.310028474977247 [###-------] 32.67%. Success rate: 47.73%
spotpython tuning: -6.310028474977247 [###-------] 33.00%. Success rate: 47.19%
spotpython tuning: -6.5544378148711955 [###-------] 33.33%. Success rate: 47.78%
spotpython tuning: -6.588306152465541 [###-------] 33.67%. Success rate: 48.35%
spotpython tuning: -6.643173524156037 [###-------] 34.00%. Success rate: 48.91%
spotpython tuning: -6.672286170081826 [###-------] 34.33%. Success rate: 49.46%
spotpython tuning: -6.672286170081826 [###-------] 34.67%. Success rate: 48.94%
spotpython tuning: -6.672286170081826 [####------] 35.00%. Success rate: 48.42%
spotpython tuning: -6.672286170081826 [####------] 35.33%. Success rate: 47.92%
spotpython tuning: -6.672286170081826 [####------] 35.67%. Success rate: 47.42%
spotpython tuning: -6.672286170081826 [####------] 36.00%. Success rate: 46.94%
spotpython tuning: -6.672286170081826 [####------] 36.33%. Success rate: 46.46%
spotpython tuning: -6.672286170081826 [####------] 36.67%. Success rate: 46.00%
spotpython tuning: -6.672286170081826 [####------] 37.00%. Success rate: 46.00%
spotpython tuning: -6.672286170081826 [####------] 37.33%. Success rate: 45.00%
spotpython tuning: -6.672286170081826 [####------] 37.67%. Success rate: 45.00%
spotpython tuning: -6.672286170081826 [####------] 38.00%. Success rate: 45.00%
spotpython tuning: -6.672286170081826 [####------] 38.33%. Success rate: 44.00%
spotpython tuning: -6.672286170081826 [####------] 38.67%. Success rate: 44.00%
spotpython tuning: -6.672286170081826 [####------] 39.00%. Success rate: 44.00%
spotpython tuning: -6.672286170081826 [####------] 39.33%. Success rate: 43.00%
spotpython tuning: -6.672286170081826 [####------] 39.67%. Success rate: 43.00%
spotpython tuning: -6.672286170081826 [####------] 40.00%. Success rate: 42.00%
spotpython tuning: -6.672286170081826 [####------] 40.33%. Success rate: 41.00%
spotpython tuning: -6.672286170081826 [####------] 40.67%. Success rate: 40.00%
spotpython tuning: -6.672286170081826 [####------] 41.00%. Success rate: 39.00%
spotpython tuning: -6.672286170081826 [####------] 41.33%. Success rate: 39.00%
spotpython tuning: -6.672286170081826 [####------] 41.67%. Success rate: 39.00%
spotpython tuning: -6.672286170081826 [####------] 42.00%. Success rate: 39.00%
spotpython tuning: -6.672286170081826 [####------] 42.33%. Success rate: 38.00%
spotpython tuning: -6.672286170081826 [####------] 42.67%. Success rate: 38.00%
spotpython tuning: -6.672286170081826 [####------] 43.00%. Success rate: 37.00%
spotpython tuning: -6.672286170081826 [####------] 43.33%. Success rate: 36.00%
spotpython tuning: -6.672286170081826 [####------] 43.67%. Success rate: 35.00%
spotpython tuning: -6.672286170081826 [####------] 44.00%. Success rate: 35.00%
spotpython tuning: -6.672286170081826 [####------] 44.33%. Success rate: 34.00%
spotpython tuning: -6.672286170081826 [####------] 44.67%. Success rate: 34.00%
spotpython tuning: -6.828491142535946 [####------] 45.00%. Success rate: 34.00%
spotpython tuning: -6.828491142535946 [#####-----] 45.33%. Success rate: 34.00%
spotpython tuning: -6.828491142535946 [#####-----] 45.67%. Success rate: 34.00%
spotpython tuning: -6.828491142535946 [#####-----] 46.00%. Success rate: 34.00%
spotpython tuning: -6.828491142535946 [#####-----] 46.33%. Success rate: 34.00%
spotpython tuning: -6.828491142535946 [#####-----] 46.67%. Success rate: 34.00%
spotpython tuning: -6.828491142535946 [#####-----] 47.00%. Success rate: 34.00%
spotpython tuning: -6.828491142535946 [#####-----] 47.33%. Success rate: 34.00%
spotpython tuning: -6.828491142535946 [#####-----] 47.67%. Success rate: 34.00%
spotpython tuning: -6.828491142535946 [#####-----] 48.00%. Success rate: 33.00%
spotpython tuning: -6.828491142535946 [#####-----] 48.33%. Success rate: 33.00%
spotpython tuning: -6.828491142535946 [#####-----] 48.67%. Success rate: 32.00%
spotpython tuning: -6.828491142535946 [#####-----] 49.00%. Success rate: 32.00%
spotpython tuning: -6.828491142535946 [#####-----] 49.33%. Success rate: 32.00%
spotpython tuning: -6.828491142535946 [#####-----] 49.67%. Success rate: 32.00%
spotpython tuning: -6.828491142535946 [#####-----] 50.00%. Success rate: 31.00%
spotpython tuning: -6.828491142535946 [#####-----] 50.33%. Success rate: 31.00%
spotpython tuning: -6.828491142535946 [#####-----] 50.67%. Success rate: 30.00%
spotpython tuning: -6.828491142535946 [#####-----] 51.00%. Success rate: 29.00%
spotpython tuning: -6.828491142535946 [#####-----] 51.33%. Success rate: 28.00%
spotpython tuning: -6.828491142535946 [#####-----] 51.67%. Success rate: 27.00%
spotpython tuning: -6.945259003466899 [#####-----] 52.00%. Success rate: 28.00%
spotpython tuning: -6.974775783227498 [#####-----] 52.33%. Success rate: 29.00%
spotpython tuning: -6.974775783227498 [#####-----] 52.67%. Success rate: 28.00%
spotpython tuning: -6.974775783227498 [#####-----] 53.00%. Success rate: 28.00%
spotpython tuning: -6.974775783227498 [#####-----] 53.33%. Success rate: 28.00%
spotpython tuning: -6.974775783227498 [#####-----] 53.67%. Success rate: 28.00%
spotpython tuning: -6.974775783227498 [#####-----] 54.00%. Success rate: 28.00%
spotpython tuning: -6.974775783227498 [#####-----] 54.33%. Success rate: 27.00%
spotpython tuning: -6.974775783227498 [#####-----] 54.67%. Success rate: 26.00%
spotpython tuning: -6.974775783227498 [######----] 55.00%. Success rate: 25.00%
spotpython tuning: -6.974775783227498 [######----] 55.33%. Success rate: 24.00%
spotpython tuning: -6.974775783227498 [######----] 55.67%. Success rate: 24.00%
spotpython tuning: -6.974775783227498 [######----] 56.00%. Success rate: 24.00%
spotpython tuning: -6.974775783227498 [######----] 56.33%. Success rate: 23.00%
spotpython tuning: -6.974775783227498 [######----] 56.67%. Success rate: 22.00%
spotpython tuning: -6.974775783227498 [######----] 57.00%. Success rate: 21.00%
spotpython tuning: -7.0037296892079866 [######----] 57.33%. Success rate: 22.00%
spotpython tuning: -7.0037296892079866 [######----] 57.67%. Success rate: 22.00%
spotpython tuning: -7.0037296892079866 [######----] 58.00%. Success rate: 21.00%
spotpython tuning: -7.0037296892079866 [######----] 58.33%. Success rate: 20.00%
spotpython tuning: -7.0037296892079866 [######----] 58.67%. Success rate: 20.00%
spotpython tuning: -7.0037296892079866 [######----] 59.00%. Success rate: 19.00%
spotpython tuning: -7.0037296892079866 [######----] 59.33%. Success rate: 18.00%
spotpython tuning: -7.0037296892079866 [######----] 59.67%. Success rate: 18.00%
spotpython tuning: -7.0037296892079866 [######----] 60.00%. Success rate: 18.00%
spotpython tuning: -7.0037296892079866 [######----] 60.33%. Success rate: 18.00%
spotpython tuning: -7.0037296892079866 [######----] 60.67%. Success rate: 18.00%
spotpython tuning: -7.0037296892079866 [######----] 61.00%. Success rate: 18.00%
spotpython tuning: -7.0037296892079866 [######----] 61.33%. Success rate: 18.00%
spotpython tuning: -7.0037296892079866 [######----] 61.67%. Success rate: 18.00%
spotpython tuning: -7.0037296892079866 [######----] 62.00%. Success rate: 17.00%
spotpython tuning: -7.0037296892079866 [######----] 62.33%. Success rate: 17.00%
spotpython tuning: -7.0037296892079866 [######----] 62.67%. Success rate: 17.00%
spotpython tuning: -7.016509782907207 [######----] 63.00%. Success rate: 17.00%
spotpython tuning: -7.024784351933507 [######----] 63.33%. Success rate: 17.00%
spotpython tuning: -7.026456286082713 [######----] 63.67%. Success rate: 17.00%
spotpython tuning: -7.026456286082713 [######----] 64.00%. Success rate: 16.00%
spotpython tuning: -7.07550232394719 [######----] 64.33%. Success rate: 16.00%
spotpython tuning: -7.081079237617379 [######----] 64.67%. Success rate: 16.00%
spotpython tuning: -7.089336137335067 [######----] 65.00%. Success rate: 16.00%
spotpython tuning: -7.089431102267706 [#######---] 65.33%. Success rate: 16.00%
spotpython tuning: -7.14292289411253 [#######---] 65.67%. Success rate: 17.00%
spotpython tuning: -7.14292289411253 [#######---] 66.00%. Success rate: 16.00%
spotpython tuning: -7.14292289411253 [#######---] 66.33%. Success rate: 16.00%
spotpython tuning: -7.14292289411253 [#######---] 66.67%. Success rate: 15.00%
spotpython tuning: -7.14292289411253 [#######---] 67.00%. Success rate: 14.00%
spotpython tuning: -7.144470718761451 [#######---] 67.33%. Success rate: 14.00%
spotpython tuning: -7.145118560920958 [#######---] 67.67%. Success rate: 14.00%
spotpython tuning: -7.151446138660958 [#######---] 68.00%. Success rate: 15.00%
spotpython tuning: -7.163813734205951 [#######---] 68.33%. Success rate: 16.00%
spotpython tuning: -7.163813734205951 [#######---] 68.67%. Success rate: 16.00%
spotpython tuning: -7.170168224045391 [#######---] 69.00%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [#######---] 69.33%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [#######---] 69.67%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [#######---] 70.00%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [#######---] 70.33%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [#######---] 70.67%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [#######---] 71.00%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [#######---] 71.33%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [#######---] 71.67%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [#######---] 72.00%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [#######---] 72.33%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [#######---] 72.67%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [#######---] 73.00%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [#######---] 73.33%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [#######---] 73.67%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [#######---] 74.00%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [#######---] 74.33%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [#######---] 74.67%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [########--] 75.00%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [########--] 75.33%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [########--] 75.67%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [########--] 76.00%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [########--] 76.33%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [########--] 76.67%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [########--] 77.00%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [########--] 77.33%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [########--] 77.67%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [########--] 78.00%. Success rate: 18.00%
spotpython tuning: -7.171873730707932 [########--] 78.33%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [########--] 78.67%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [########--] 79.00%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [########--] 79.33%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [########--] 79.67%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [########--] 80.00%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [########--] 80.33%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [########--] 80.67%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [########--] 81.00%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [########--] 81.33%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [########--] 81.67%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [########--] 82.00%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [########--] 82.33%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [########--] 82.67%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [########--] 83.00%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [########--] 83.33%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [########--] 83.67%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [########--] 84.00%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [########--] 84.33%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [########--] 84.67%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [########--] 85.00%. Success rate: 17.00%
spotpython tuning: -7.171873730707932 [#########-] 85.33%. Success rate: 16.00%
spotpython tuning: -7.171873730707932 [#########-] 85.67%. Success rate: 15.00%
spotpython tuning: -7.171873730707932 [#########-] 86.00%. Success rate: 15.00%
spotpython tuning: -7.171873730707932 [#########-] 86.33%. Success rate: 15.00%
spotpython tuning: -7.171873730707932 [#########-] 86.67%. Success rate: 15.00%
spotpython tuning: -7.171873730707932 [#########-] 87.00%. Success rate: 15.00%
spotpython tuning: -7.171873730707932 [#########-] 87.33%. Success rate: 15.00%
spotpython tuning: -7.171873730707932 [#########-] 87.67%. Success rate: 15.00%
spotpython tuning: -7.171873730707932 [#########-] 88.00%. Success rate: 15.00%
spotpython tuning: -7.171873730707932 [#########-] 88.33%. Success rate: 15.00%
spotpython tuning: -7.171873730707932 [#########-] 88.67%. Success rate: 15.00%
spotpython tuning: -7.174064767390577 [#########-] 89.00%. Success rate: 16.00%
spotpython tuning: -7.175633207006685 [#########-] 89.33%. Success rate: 17.00%
spotpython tuning: -7.176167974852747 [#########-] 89.67%. Success rate: 18.00%
spotpython tuning: -7.176167974852747 [#########-] 90.00%. Success rate: 18.00%
spotpython tuning: -7.189096361854769 [#########-] 90.33%. Success rate: 19.00%
spotpython tuning: -7.191662552650487 [#########-] 90.67%. Success rate: 19.00%
spotpython tuning: -7.204675110758117 [#########-] 91.00%. Success rate: 20.00%
spotpython tuning: -7.269743775766366 [#########-] 91.33%. Success rate: 21.00%
spotpython tuning: -7.284947659471473 [#########-] 91.67%. Success rate: 22.00%
spotpython tuning: -7.288847560734197 [#########-] 92.00%. Success rate: 23.00%
spotpython tuning: -7.2949198856524955 [#########-] 92.33%. Success rate: 24.00%
spotpython tuning: -7.319513418939947 [#########-] 92.67%. Success rate: 25.00%
spotpython tuning: -7.319513418939947 [#########-] 93.00%. Success rate: 25.00%
spotpython tuning: -7.327412928238721 [#########-] 93.33%. Success rate: 26.00%
spotpython tuning: -7.330189718100601 [#########-] 93.67%. Success rate: 27.00%
spotpython tuning: -7.355096178357785 [#########-] 94.00%. Success rate: 28.00%
spotpython tuning: -7.39502733039102 [#########-] 94.33%. Success rate: 29.00%
spotpython tuning: -7.39502733039102 [#########-] 94.67%. Success rate: 29.00%
spotpython tuning: -7.39502733039102 [##########] 95.00%. Success rate: 29.00%
spotpython tuning: -7.456634123567914 [##########] 95.33%. Success rate: 30.00%
spotpython tuning: -7.47893126552023 [##########] 95.67%. Success rate: 31.00%
spotpython tuning: -7.4807104943619835 [##########] 96.00%. Success rate: 32.00%
spotpython tuning: -7.4807104943619835 [##########] 96.33%. Success rate: 31.00%
spotpython tuning: -7.482815602090074 [##########] 96.67%. Success rate: 31.00%
spotpython tuning: -7.482815602090074 [##########] 97.00%. Success rate: 30.00%
spotpython tuning: -7.482815602090074 [##########] 97.33%. Success rate: 30.00%
spotpython tuning: -7.482815602090074 [##########] 97.67%. Success rate: 29.00%
spotpython tuning: -7.482815602090074 [##########] 98.00%. Success rate: 28.00%
spotpython tuning: -7.482815602090074 [##########] 98.33%. Success rate: 27.00%
spotpython tuning: -7.505818777690039 [##########] 98.67%. Success rate: 27.00%
spotpython tuning: -7.52372847684019 [##########] 99.00%. Success rate: 27.00%
spotpython tuning: -7.525246601190698 [##########] 99.33%. Success rate: 28.00%
spotpython tuning: -7.525246601190698 [##########] 99.67%. Success rate: 28.00%
spotpython tuning: -7.525740881903069 [##########] 100.00%. Success rate: 29.00% Done...
Experiment saved to 000_res.pkl
<spotpython.spot.spot.Spot at 0x326796490>
S_micha.plot_progress(log_y=False, title="sklearn Kriging Progress with y")
print(f"[10D] Kriging y: min y = {S_micha.min_y:.4f} at x = {S_micha.min_X}")[10D] Kriging y: min y = -7.5257 at x = [2.10228431 2.70249094 2.21713328 2.485069 2.62812863 2.02849383
2.22044232 1.35809939 1.28131032 1.21812455]
Plot of the surrogate model in the first two dimensions:
from spotpython.plot.contour import plotModel
model = S_micha.surrogate
fig, axes = plotModel(
model=model,
lower=lower,
upper=upper,
i=0,
j=1,
n_grid=100,
contour_levels=20,
)
25.2.5 Evaluation of 30 repeats with Kriging and Matern kernel
Sine 30 repeats were performed and stored in spot_michalewicz.json, we can now evaluate the results:
import json
import numpy as np
# Load results from spot_michalewicz.json
with open("spot_michalewicz.json", "r") as f:
data = json.load(f)
# Extract all "evaluations" values
evals = [
iteration["sampled_locations"][0]["evaluations"]
for iteration in data["search_iterations"]
]
# Compute mean and standard deviation
mean_eval = np.mean(evals)
std_eval = np.std(evals)
print(f"Mean of evaluations: {mean_eval:.6f}")
print(f"Standard deviation of evaluations: {std_eval:.6f}")Mean of evaluations: -5.390014
Standard deviation of evaluations: 1.048200
25.3 Jupyter Notebook
- The Jupyter-Notebook of this chapter is available on GitHub in the Hyperparameter-Tuning-Cookbook Repository