Class BayesianOptimizer<T, TInput, TOutput>
- Namespace
- AiDotNet.Optimizers
- Assembly
- AiDotNet.dll
Represents a Bayesian Optimizer for optimization problems.
public class BayesianOptimizer<T, TInput, TOutput> : OptimizerBase<T, TInput, TOutput>, IOptimizer<T, TInput, TOutput>, IModelSerializer
Type Parameters
TThe numeric type used for calculations (e.g., float, double).
TInputTOutput
- Inheritance
-
OptimizerBase<T, TInput, TOutput>BayesianOptimizer<T, TInput, TOutput>
- Implements
-
IOptimizer<T, TInput, TOutput>
- Inherited Members
- Extension Methods
Remarks
Bayesian Optimization is a powerful technique for optimizing black-box functions that are expensive to evaluate. It uses a probabilistic model to make predictions about the function's behavior and decides where to sample next.
For Beginners: Think of this optimizer as a smart guessing game. It tries to find the best solution by making educated guesses based on what it has learned from previous attempts. It's particularly useful when each guess is time-consuming or expensive to evaluate.
Constructors
BayesianOptimizer(IFullModel<T, TInput, TOutput>, BayesianOptimizerOptions<T, TInput, TOutput>?, IGaussianProcess<T>?, IEngine?)
Initializes a new instance of the BayesianOptimizer class.
public BayesianOptimizer(IFullModel<T, TInput, TOutput> model, BayesianOptimizerOptions<T, TInput, TOutput>? options = null, IGaussianProcess<T>? gaussianProcess = null, IEngine? engine = null)
Parameters
modelIFullModel<T, TInput, TOutput>The model to optimize.
optionsBayesianOptimizerOptions<T, TInput, TOutput>The options for configuring the Bayesian Optimization algorithm.
gaussianProcessIGaussianProcess<T>The Gaussian Process model to use for approximating the objective function.
engineIEngine
Remarks
For Beginners: This sets up the Bayesian Optimizer with its initial configuration. You can customize various aspects of how it works, or use default settings. The Gaussian Process is a key component that helps the optimizer make predictions about unknown points.
Methods
Deserialize(byte[])
Restores the state of the optimizer from a byte array.
public override void Deserialize(byte[] data)
Parameters
databyte[]The byte array containing the serialized state of the optimizer.
Remarks
For Beginners: This method takes a saved state of the Bayesian Optimizer (in the form of a byte array) and uses it to restore the optimizer to that state. It's like loading a saved game, bringing back all the important settings and progress that were saved earlier.
GetOptions()
Gets the current options for the Bayesian Optimization algorithm.
public override OptimizationAlgorithmOptions<T, TInput, TOutput> GetOptions()
Returns
- OptimizationAlgorithmOptions<T, TInput, TOutput>
The current optimization options.
Remarks
For Beginners: This method lets you see what settings the Bayesian Optimization algorithm is currently using.
InitializeAdaptiveParameters()
Initializes the adaptive parameters used in the Bayesian Optimization algorithm.
protected override void InitializeAdaptiveParameters()
Remarks
For Beginners: This method sets up the initial state for the optimizer. It clears any previously sampled points and their corresponding values, preparing for a fresh optimization run.
Optimize(OptimizationInputData<T, TInput, TOutput>)
Performs the main optimization process using the Bayesian Optimization algorithm.
public override OptimizationResult<T, TInput, TOutput> Optimize(OptimizationInputData<T, TInput, TOutput> inputData)
Parameters
inputDataOptimizationInputData<T, TInput, TOutput>The input data for the optimization process.
Returns
- OptimizationResult<T, TInput, TOutput>
The result of the optimization process.
Remarks
For Beginners: This is the heart of the Bayesian Optimization algorithm. It starts by taking some random samples, then iteratively uses what it has learned to make smart guesses about where the best solution might be. It keeps doing this until it finds a good solution or runs out of allowed attempts.
Serialize()
Converts the current state of the optimizer into a byte array for storage or transmission.
public override byte[] Serialize()
Returns
- byte[]
A byte array representing the serialized state of the optimizer.
Remarks
For Beginners: This method takes all the important information about the current state of the Bayesian Optimizer and turns it into a format that can be easily saved or sent to another computer.
UpdateOptions(OptimizationAlgorithmOptions<T, TInput, TOutput>)
Updates the options for the Bayesian Optimization algorithm.
protected override void UpdateOptions(OptimizationAlgorithmOptions<T, TInput, TOutput> options)
Parameters
optionsOptimizationAlgorithmOptions<T, TInput, TOutput>The new options to be set.
Remarks
For Beginners: This method allows you to change how the Bayesian Optimization algorithm behaves by updating its settings. It checks to make sure you're providing the right kind of settings.
Exceptions
- ArgumentException
Thrown when the provided options are not of the correct type.