Grid search tuning strategy for model hyperparameter optimisation.
More...
#include <GridSearchTuner.h>
|
| | 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.
|
| |
| 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.
|
| |
|
| void | tune_impl (Estimator &estimator, ConstMatrixRef training_inputs, const OutputComputer &training_outputs) const override |
| | Optimise the kernel hyperparameters.
|
| |
|
|
std::size_t | n_jobs_ |
| | Number of parallel jobs to run during tuning.
|
| |
|
std::vector< ParameterValues > | parameters_ |
| | 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.
|
| |
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
◆ 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
-
| parameters | parameters to be tuned, with the values to be tested |
| n_jobs | number of parallel jobs to run during tuning. If set to 0, it defaults to max(1, CPU cores - 2). |
◆ 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
-
| estimator | estimator to optimise |
| training_inputs | training input data |
| training_outputs | training 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: