RandomSearchOptimizer<T, TInput, TOutput>

Models & Types · AiDotNet.HyperparameterOptimization

Implements random search hyperparameter optimization.

Inheritance: HyperparameterOptimizerBase<T, TInput, TOutput> → RandomSearchOptimizer<T, TInput, TOutput>

How It Works

For Beginners: Random search randomly tries different hyperparameter combinations. While simple, it’s surprisingly effective and often outperforms grid search, especially when some hyperparameters are more important than others.

How it works:

  1. Randomly sample hyperparameter values from the search space
  2. Train/evaluate the model with those hyperparameters
  3. Record the results
  4. Repeat for the specified number of trials
  5. Return the best configuration found

Constructors

Constructor Summary
RandomSearchOptimizer(bool maximize, int? seed) Initializes a new instance of the RandomSearchOptimizer class.

Methods

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