The class HyperParameterTuner for the given MLAlgorithm utilizes the provided Optimizer to find the values of hyper-parameters that optimize the value of the given Metric. More...
Public Member Functions | |
template<typename... CVArgs> | |
HyperParameterTuner (const CVArgs &...args) | |
Create a HyperParameterTuner object by passing constructor arguments for the given cross-validation strategy (the CV class). More... | |
const MLAlgorithm & | BestModel () const |
Get the best model from the last run. More... | |
MLAlgorithm & | BestModel () |
Modify the best model from the last run. More... | |
double | BestObjective () const |
Get the performance measurement of the best model from the last run. More... | |
double | MinDelta () const |
Get minimum increase of arguments for calculation of partial derivatives (by the definition) in gradient-based optimization. More... | |
double & | MinDelta () |
Modify minimum increase of arguments for calculation of partial derivatives (by the definition) in gradient-based optimization. More... | |
template<typename... Args> | |
TupleOfHyperParameters< Args... > | Optimize (const Args &... args) |
Find the best hyper-parameters by using the given Optimizer. More... | |
OptimizerType & | Optimizer () |
Access and modify the optimizer. More... | |
double | RelativeDelta () const |
Get relative increase of arguments for calculation of partial derivatives (by the definition) in gradient-based optimization. More... | |
double & | RelativeDelta () |
Modify relative increase of arguments for calculation of partial derivatives (by the definition) in gradient-based optimization. More... | |
The class HyperParameterTuner for the given MLAlgorithm utilizes the provided Optimizer to find the values of hyper-parameters that optimize the value of the given Metric.
The value of the Metric is calculated by performing cross-validation with the provided cross-validation strategy.
To construct a HyperParameterTuner object you need to pass the same arguments as for construction of an object of the given CV class. For example, we can use the following code to try to find a good lambda value for LinearRegression.
When some hyper-parameters should not be optimized, you can specify values for them with the Fixed function as in the following example of finding good lambda1 and lambda2 values for LARS.
MLAlgorithm | A machine learning algorithm. |
Metric | A metric to assess the quality of a trained model. |
CV | A cross-validation strategy used to assess a set of hyper-parameters. |
OptimizerType | An optimization strategy (GridSearch and GradientDescent are supported). |
MatType | The type of data. |
PredictionsType | The type of predictions (should be passed when the predictions type is a template parameter in Train methods of the given MLAlgorithm; arma::Row<size_t> will be used otherwise). |
WeightsType | The type of weights (should be passed when weighted learning is supported, and the weights type is a template parameter in Train methods of the given MLAlgorithm; arma::vec will be used otherwise). |
HyperParameterTuner | ( | const CVArgs &... | args | ) |
Create a HyperParameterTuner object by passing constructor arguments for the given cross-validation strategy (the CV class).
args | Constructor arguments for the given cross-validation strategy (the CV class). |
|
inline |
|
inline |
|
inline |
|
inline |
Get minimum increase of arguments for calculation of partial derivatives (by the definition) in gradient-based optimization.
This value is going to be used when it is greater than the increase calculated with the rules described in the documentation for RelativeDelta().
The default value is 1e-10.
|
inline |
Modify minimum increase of arguments for calculation of partial derivatives (by the definition) in gradient-based optimization.
This value is going to be used when it is greater than the increase calculated with the rules described in the documentation for RelativeDelta().
The default value is 1e-10.
TupleOfHyperParameters<Args...> Optimize | ( | const Args &... | args | ) |
Find the best hyper-parameters by using the given Optimizer.
For each hyper-parameter one of the following should be passed as an argument.
All arguments should be passed in the same order as if the corresponding hyper-parameters would be passed into the Evaluate method of the given CV class (in the order as they appear in the constructor(s) of the given MLAlgorithm). Also, arguments for all required hyper-parameters (ones that don't have default values in the corresponding MLAlgorithm constructor) should be provided.
The method returns a tuple of values for hyper-parameters that haven't been fixed.
args | Arguments corresponding to hyper-parameters (see the method description for more information). |
Referenced by HyperParameterTuner< MLAlgorithm, Metric, CV, OptimizerType, MatType, PredictionsType, WeightsType >::MinDelta().
|
inline |
|
inline |
Get relative increase of arguments for calculation of partial derivatives (by the definition) in gradient-based optimization.
The exact increase for some particular argument is equal to the absolute value of the argument multiplied by the relative increase (see also the documentation for MinDelta()).
The default value is 0.01.
|
inline |
Modify relative increase of arguments for calculation of partial derivatives (by the definition) in gradient-based optimization.
The exact increase for some particular argument is equal to the absolute value of the argument multiplied by the relative increase (see also the documentation for MinDelta()).
The default value is 0.01.