BayesianOptimizer<T, TInput, TOutput>

Models & Types ยท AiDotNet.HyperparameterOptimization

Implements Bayesian optimization for hyperparameter tuning using Gaussian Process regression.

Inheritance: HyperparameterOptimizerBase<T, TInput, TOutput> โ†’ BayesianOptimizer<T, TInput, TOutput>

How It Works

For Beginners: Bayesian optimization is a smart search strategy that learns from previous trials to decide what to try next. Unlike grid or random search, it:

  • Builds a model of how hyperparameters affect performance
  • Uses this model to focus on promising regions
  • Balances exploration (trying new areas) with exploitation (refining good areas)

This makes it much more efficient than random search, often finding good hyperparameters in 10-20 trials instead of 100s.

Key components:

  • Surrogate Model: A Gaussian Process that predicts performance for any hyperparameter combination
  • Acquisition Function: Decides where to sample next based on predicted mean and uncertainty
  • Sequential Optimization: Each trial informs the next, unlike parallel random search

Constructors

Constructor Summary
BayesianOptimizer(bool maximize, AcquisitionFunctionType acquisitionFunction, int nInitialPoints, double explorationWeight, int? seed) Initializes a new instance of the BayesianOptimizer class.

Methods

Method Summary
Dictionary<string, object> SuggestNext(HyperparameterTrial<T> trial) Suggests the next hyperparameter configuration using the acquisition function.
HyperparameterOptimizationResult<T> Optimize(Func<Dictionary<string, object>, T> objectiveFunction, HyperparameterSearchSpace searchSpace, int nTrials) Searches for the best hyperparameter configuration using Bayesian optimization.