Animation
Animation of active learning for simple 1D functions. Can be used for demonstration purposes.
- PyALAF.animation.create_animation(model, gpr, acquisition_function, grid_simple, n_iterations=30, alpha=0, n_observations=3, noise_level=0, html=True, random_state=42, legend=True, plot_std=True, custom_acfn_input=None)[source]
Create an animation for Active Learning on a 1-dimenional function. The Active Learning is only done on the discrete grid, which must be provided. This is useful for illustration purposes.
- Parameters:
model (Model class) – PyAL model class that generates the (noisy) data.
gpr (Sciit-Learn Model) – Scikit-Learn Model, use GaussianProcessRegression model here, since it supports all acquisition functions.
acquisition_function (str or callable) – Name of the acquisition function or a callable. Choose from: ei, poi, ucb, random, std, ideal, uidal, GSx, GSy, iGS, sGSx. QBC must implemented separately.
grid_simple (nd_array) – A simple grid in one dimension.
n_iterations (int, optional) – Number of Active Learning steps, by default 30
alpha (int, optional) – Hyperparameter of the given acquisition function, by default 0
n_observations (int, optional) – Number of initial observations, by default 3
noise_level (int, optional) – Standard deviation of Gaussian noise, by default 0
html (bool, optional) – Whether to convert the animation to html format, by default True
random_state (int, optional) – Random state for reproducibility, by default 42
legend (bool, optional) – Whether to show a legend in the animation, by default True.
plot_std (bool, optional.) – Whether to plot the standard deviation, by default True.
custom_acfn_input (dict) – Dictionary that contains which information is used by a custom acquisition function. The default is None.
- Returns:
Animation of the Active Learning process.
- Return type:
matplotlib animation
- PyALAF.animation.create_animation_continuous(model, gpr, acquisition_function, grid_simple, n_iterations=30, alpha=0, n_observations=3, noise_level=0, html=True, random_state=42, opt_method='lbfgs', pso_options=None, legend=False, plot_std=False, custom_acfn_input=None)[source]
Create an animation for Active Learning on a 1-dimenional function. The Active Learning is done in continuous space using either LBFGS or PSO optimization. A grid must be given do define the boundaries and for plotting. This is useful for illustration purposes.
- Parameters:
model (Model class) – PyAL model class that generates the (noisy) data.
gpr (Sciit-Learn Model) – Scikit-Learn Model, use GaussianProcessRegression model here, since it supports all acquisition functions.
acquisition_function (str or callable) – Name of the acquisition function or a callable. Choose from: ei, poi, ucb, random, std, ideal, uidal, GSx, GSy, iGS, sGSx. QBC must implemented separately.
grid_simple (nd_array) – A simple grid in one dimension.
n_iterations (int, optional) – Number of Active Learning steps, by default 30
alpha (int, optional) – Hyperparameter of the given acquisition function, by default 0
n_observations (int, optional) – Number of initial observations, by default 3
noise_level (int, optional) – Standard deviation of Gaussian noise, by default 0
html (bool, optional) – Whether to convert the animation to html format, by default True
random_state (int, optional) – Random state for reproducibility, by default 42
opt_method (str, optional) – Choose from scipy (using lbfgs algorithm) or PSO (using PySwarms). The default value is “lbfgs”.
pso_options (dict, optional) – Options for PySwarms GlobalBestOptimizer. The default value is “{}”.
legend (bool, optional) – Whether to show a legend in the animation, by default True
plot_std (bool, optional.) – Whether to plot the standard deviation, by default True.
custom_acfn_input (dict) – Dictionary that contains which information is used by a custom acquisition function. The default is {}.
- Returns:
Animation of the Active Learning process.
- Return type:
matplotlib animation
- PyALAF.animation.max_acquisition(acquisition, grid, rng=None)[source]
Find the maximum of a function on a discrete grid
- Parameters:
acquisition (nd_array) – Array that containes the values of the acquisition function on given grid points.
grid (nd_array) – Array that contains the grid points.
rng (Numpy Random Number Generator, optional) – Numpy Random Number Generator object. The default is “None”.
- Returns:
nd_array – Grid point for which the acquisition function has its maximum.
float – Maximum value of the acquisition function.
int – Index of the grid point for which the acquisition function has its maximum.