lucid  0.0.1
Lifting-based Uncertain Control Invariant Dynamics
Loading...
Searching...
No Matches
lucid::GridSearchTuner Class Referencefinal

Grid search tuning strategy for model hyperparameter optimisation. More...

#include <GridSearchTuner.h>

Inheritance diagram for lucid::GridSearchTuner:
lucid::Tuner

Public Member Functions

 GridSearchTuner (std::vector< ParameterValues > parameters, std::size_t n_jobs=0)
 Construct a new GridSearchTuner object with the given parameters.
 
std::size_t n_jobs () const
 Get read-only access to the number of parallel jobs of the grid search.
 
const std::vector< ParameterValues > & parameters () const
 Get read-only access to the parameters of the grid search.
 
std::string to_string () const override
 Obtain the string representation of this object.
 
- Public Member Functions inherited from lucid::Tuner
void tune (Estimator &estimator, ConstMatrixRef training_inputs, ConstMatrixRef training_outputs) const
 Optimise the kernel hyperparameters.
 
void tune_online (Estimator &estimator, ConstMatrixRef training_inputs, const OutputComputer &training_outputs) const
 Optimise the kernel hyperparameters.
 

Private Member Functions

void tune_impl (Estimator &estimator, ConstMatrixRef training_inputs, const OutputComputer &training_outputs) const override
 Optimise the kernel hyperparameters.
 

Private Attributes

std::size_t n_jobs_
 Number of parallel jobs to run during tuning.
 
std::vector< ParameterValuesparameters_
 List of parameter values to be tuned, with the values to be tested.
 
std::vector< Index > parameters_max_indices_
 Maximum indices for each parameter, used to iterate over the grid.
 

Detailed Description

Grid search tuning strategy for model hyperparameter optimisation.

The GridSearchTuner is responsible for iterating over a predefined grid of hyperparameter combinations to optimise the performance of a given estimator. More precisely, the Estimator::score method is called for each combination of hyperparameters, keeping track of the best combination (i.e., the one producing the highest value) found during the search. When all combinations have been evaluated, the best hyperparameters are set on the estimator. This tuner is suitable for scenarios where exhaustive search over a finite hyperparameter space is required.

See also
scorer::r2_score

Constructor & Destructor Documentation

◆ GridSearchTuner()

lucid::GridSearchTuner::GridSearchTuner ( std::vector< ParameterValues > parameters,
std::size_t n_jobs = 0 )
explicit

Construct a new GridSearchTuner object with the given parameters.

Parameters
parametersparameters to be tuned, with the values to be tested
n_jobsnumber of parallel jobs to run during tuning. If set to 0, it defaults to max(1, CPU cores - 2).

Member Function Documentation

◆ n_jobs()

std::size_t lucid::GridSearchTuner::n_jobs ( ) const
inlinenodiscard

Get read-only access to the number of parallel jobs of the grid search.

Returns
number of parallel jobs of the grid search

◆ parameters()

const std::vector< ParameterValues > & lucid::GridSearchTuner::parameters ( ) const
inlinenodiscard

Get read-only access to the parameters of the grid search.

Returns
parameters of the grid search

◆ to_string()

std::string lucid::GridSearchTuner::to_string ( ) const
nodiscardoverridevirtual

Obtain the string representation of this object.

Returns
string representation of this object

Reimplemented from lucid::Tuner.

◆ tune_impl()

void lucid::GridSearchTuner::tune_impl ( Estimator & estimator,
ConstMatrixRef training_inputs,
const OutputComputer & training_outputs ) const
overrideprivatevirtual

Optimise the kernel hyperparameters.

Starting from the initial guess, the optimiser finds the best hyperparameters for the kernel. It is up to the subclass to determine the optimisation algorithm used.

Note
The method must call the consolidate method of the estimator to ensure that the kernel is ready to be used.
Precondition
The number of rows in the training inputs should be equal to the number of rows in the training outputs.
Todo
If the OutputComputer becomes a bottleneck, consider having a separate method for when the outputs are available from the get-go.
Parameters
estimatorestimator to optimise
training_inputstraining input data
training_outputstraining output data. It uses an OutputComputer to compute the outputs when needed

Implements lucid::Tuner.


The documentation for this class was generated from the following files: