Skip to contents

The function uses a Genetic Algorithm implementation to optimize the model hyperparameter configuration according to the chosen metric.

Usage

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
)

Arguments

model

SDMmodel or SDMmodelCV object.

hypers

named list containing the values of the hyperparameters that should be tuned, see details.

metric

character. The metric used to evaluate the models, possible values are: "auc", "tss" and "aicc".

test

SWD object. Testing dataset used to evaluate the model, not used with aicc and SDMmodelCV objects.

pop

numeric. Size of the population.

gen

numeric. Number of generations.

env

rast containing the environmental variables, used only with "aicc".

keep_best

numeric. Percentage of the best models in the population to be retained during each iteration, expressed as decimal number.

keep_random

numeric. Probability of retaining the excluded models during each iteration, expressed as decimal number.

mutation_chance

numeric. Probability of mutation of the child models, expressed as decimal number.

interactive

logical. If FALSE the interactive chart is not created.

progress

logical. If TRUE shows a progress bar.

seed

numeric. The value used to set the seed to have consistent results.

Value

SDMtune object.

Details

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.

See also

Author

Sergio Vignali

Examples