9Handling Noise: Optimal Computational Budget Allocation in Spot
This notebook demonstrates how noisy functions can be handled with OCBA by Spot.
9.1 Example: Spot, OCBA, and the Noisy Sphere Function
import numpy as npfrom math import inffrom spotPython.fun.objectivefunctions import analyticalfrom spotPython.spot import spotimport matplotlib.pyplot as pltfrom spotPython.utils.fileimport get_experiment_namefrom spotPython.utils.init import fun_control_initfrom spotPython.utils.fileimport get_spot_tensorboard_pathPREFIX ="09"experiment_name = get_experiment_name(prefix=PREFIX)print(experiment_name)
09_bartz08-2_2023-07-10_00-22-55
9.1.1 The Objective Function: Noisy Sphere
The spotPython package provides several classes of objective functions. We will use an analytical objective function with noise, i.e., a function that can be described by a (closed) formula: \[f(x) = x^2 + \epsilon\]
Since sigma is set to 0.1, noise is added to the function:
fun = analytical().fun_spherefun_control = fun_control_init( spot_tensorboard_path=get_spot_tensorboard_path(experiment_name), sigma=0.1, seed=123,)
A plot illustrates the noise:
x = np.linspace(-1,1,100).reshape(-1,1)y = fun(x, fun_control=fun_control)plt.figure()plt.plot(x,y, "k")plt.show()
Spot is adopted as follows to cope with noisy functions:
fun_repeats is set to a value larger than 1 (here: 2)
noise is set to true. Therefore, a nugget (Lambda) term is added to the correlation matrix
init size (of the design_control dictionary) is set to a value larger than 1 (here: 2)