BayesianMinimization

BayesianMinimization [f,{conf1,conf2,}]

gives an object representing the result of Bayesian minimization of the function f over the configurations confi.

BayesianMinimization[f,reg]

minimizes over the region represented by the region specification reg.

BayesianMinimization[f,sampler]

minimizes over configurations obtained by applying the function sampler.

BayesianMinimization [f,{conf1,conf2,}nsampler]

applies the function nsampler to successively generate configurations starting from the confi.

Details and Options

  • BayesianMinimization[] returns a BayesianMinimizationObject[] whose properties can be obtained using BayesianMinimizationObject[]["prop"].
  • Possible properties include:
  • "EvaluationHistory"configurations and values explored during minimization
    "Method"method used for Bayesian minimization
    "MinimumConfiguration"configuration found that minimizes the result from f
    "MinimumValue"estimated minimum value obtained from f
    "NextConfiguration"configuration to sample next if minimization were continued
    "PredictorFunction"best prediction model found for the function f
    "Properties"list of all available properties
  • Configurations can be of any form accepted by Predict (single data element, list of data elements, association of data elements, etc.) and of any type accepted by Predict (numerical, textual, sounds, images, etc.).
  • The function f must output a real-number value when applied to a configuration conf.
  • BayesianMinimization[f,] attempts to find a good minimum using the smallest number of evaluations of f.
  • In BayesianMinimization[f,spec], spec defines the domain of the function f. A domain can be defined by a list of configurations, a geometric region, or a configuration generator function.
  • In BayesianMinimization[f,sampler], sampler[] must output a configuration suitable for f to be applied to it.
  • In BayesianMinimization[f,{conf1,conf2,}->nsampler], nsampler[conf] must output a configuration.
  • BayesianMinimization takes the following options:
  • AssumeDeterministic Falsewhether to assume that f is deterministic
    InitialEvaluationHistory Noneintial set of configurations and values
    MaxIterations 100maximum number of iterations
    Method Automaticmethod used to determine configurations to evaluate
    ProgressReporting$ProgressReportinghow to report progress
    RandomSeeding1234what seeding of pseudorandom generators should be done internally
  • Possible settings for Method include:
  • Automaticpick the method automatically
    "MaxExpectedImprovement"maximize expected improvement over current best value
    "MaxImprovementProbability"maximize improvement probability over current best value
  • Possible settings for RandomSeeding include:
  • Automaticautomatically reseed every time the function is called
    Inheriteduse externally seeded random numbers
    seeduse an explicit integer or strings as a seed

Examples

open allclose all

Basic Examples  (3)

Minimize a function over an interval:

Use the resulting BayesianMinimizationObject[] to get the estimated minimum configuration:

Get the estimated minimum function value:

Minimize a function over a set of configurations:

Get the minimum configuration over the set:

Minimize a function over a domain defined by a random generator:

Get the estimated minimum value:

Scope  (3)

Minimize a function over a region:

Get the list of available properties to query:

Get the history of evaluations:

Get information about the method used to determine the configurations to explore:

Get the current probabilistic model of the function (this is a PredictorFunction):

Find the best configuration to explore if the minimization were continued:

Find a list of properties simultaneously:

Visualize how well the function is modeled, particularly near the minimum:

Minimize a function with initial configurations over a domain defined by a random neighborhood configuration generator:

Get the model of the function:

Visualize the model's performance near the minimum:

Define a function that takes an image and computes the negative probability returned by ImageIdentify of identifying the image as the entity , with the domain defined by a random generator over a corpus of images:

Minimize the function above:

Get the minimum configuration:

Get the evaluation history:

Options  (4)

AssumeDeterministic  (1)

Minimize a function over a domain defined by a random generator:

The function is assumed to be stochastic; the value from the probabilistic model will differ in general from the function value for evaluated configurations:

Include information that the function is deterministic, i.e. noise free:

For a deterministic function, the model value and the function value for evaluated configurations agree to a good precision:

InitialEvaluationHistory  (1)

Minimize a function over a disk region with a small number of iterations:

Use the information from this evaluation in the next:

Get the estimated minimum configuration now:

MaxIterations  (1)

Minimize a function with a domain defined by a random generator:

Get the number of function evaluations:

Specify the maximum number of iterations:

Method  (1)

Define a function over an interval region:

Specify the method for exploring configurations:

Specify a different method:

Applications  (2)

Define a training set to train predictor functions using the Predict function and a test set to measure their performance:

Create a "loss" function to test the performance of different methods in Predict:

Minimize the loss function over a domain defined by a list of different methods for Predict:

Examine the evaluation history:

Find the best configuration to explore next:

Load Fisher's Iris dataset and divide it into a training set and a validation set:

Create "blackbox" functions. Here the functions are the loss (negative log-likelihood) functions for two different methods used in the Classify function. The arguments of the functions are known as hyperparameters.

Train a logistic regression classifier with two hyperparameters, the L1 and L2 regularization coefficients:

Minimize the loss function for the logistic regression classifier over a domain defined by a rectangular region in the logarithm of the hyperparameters:

Get the model of the function:

Visualize the model of the loss function of the classifier together with the estimated minimum:

Now train a support vector machine (SVM) classifier with two hyperparameters, the soft margin parameter and the gamma scaling parameter:

Minimize the loss function for the SVM classifier over a domain defined by a rectangular region in the logarithm of the hyperparameters:

Get the model of the function:

Visualize the model of the loss function together with the estimated minimum:

Possible Issues  (2)

When the domain of the objective function is defined by an initial configuration set and a neighborhood configuration generator, the results depend on the quality of the generator provided.

Minimize a function where the domain is defined as above:

Get the model of the function:

Since the starting initial configurations are "far" from the global minimum and the generator takes relatively small steps, the algorithm could converge to a local minimum:

If the neighborhood configuration generator takes steps that are "too large" or "too small", this could lead to problems:

In this case, at each step the generator gives a configuration value that is the square of the previous one, so the values quickly become extremely large and the probabilistic model does not work properly.

Wolfram Research (2016), BayesianMinimization, Wolfram Language function, https://reference.wolfram.com/language/ref/BayesianMinimization.html (updated 2017).

Text

Wolfram Research (2016), BayesianMinimization, Wolfram Language function, https://reference.wolfram.com/language/ref/BayesianMinimization.html (updated 2017).

CMS

Wolfram Language. 2016. "BayesianMinimization." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017. https://reference.wolfram.com/language/ref/BayesianMinimization.html.

APA

Wolfram Language. (2016). BayesianMinimization. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/BayesianMinimization.html

BibTeX

@misc{reference.wolfram_2024_bayesianminimization, author="Wolfram Research", title="{BayesianMinimization}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/BayesianMinimization.html}", note=[Accessed: 22-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_bayesianminimization, organization={Wolfram Research}, title={BayesianMinimization}, year={2017}, url={https://reference.wolfram.com/language/ref/BayesianMinimization.html}, note=[Accessed: 22-December-2024 ]}