The function uses a Genetic Algorithm implementation to optimize the model hyperparameter configuration according to the chosen metric.
optimizeModel(
model,
hypers,
metric,
test = NULL,
pop = 20,
gen = 5,
env = NULL,
keep_best = 0.4,
keep_random = 0.2,
mutation_chance = 0.4,
interactive = TRUE,
progress = TRUE,
seed = NULL
)
SDMtune object.
SDMmodel or SDMmodelCV object.
named list containing the values of the hyperparameters that should be tuned, see details.
character. The metric used to evaluate the models, possible values are: "auc", "tss" and "aicc".
SWD object. Testing dataset used to evaluate the model, not used with aicc and SDMmodelCV objects.
numeric. Size of the population.
numeric. Number of generations.
rast containing the environmental variables, used only with "aicc".
numeric. Percentage of the best models in the population to be retained during each iteration, expressed as decimal number.
numeric. Probability of retaining the excluded models during each iteration, expressed as decimal number.
numeric. Probability of mutation of the child models, expressed as decimal number.
logical. If FALSE
the interactive chart is not created.
logical. If TRUE
shows a progress bar.
numeric. The value used to set the seed to have consistent results.
Sergio Vignali
To know which hyperparameters can be tuned you can use the output
of the function getTunableArgs. Hyperparameters not included in the
hypers
argument take the value that they have in the passed model.
An interactive chart showing in real-time the steps performed by the algorithm is displayed in the Viewer pane.
Part of the code is inspired by this post.
gridSearch and randomSearch.