Ancillary genetic algorithm functions
Built-in functions related to genetic algorithms
gafs_initial(vars, popSize, ...)gafs_lrSelection(population, fitness, r = NULL, q = NULL, ...)gafs_rwSelection(population, fitness, ...)gafs_tourSelection(population, fitness, k = 3, ...)gafs_spCrossover(population, fitness, parents, ...)gafs_uCrossover(population, parents, ...)gafs_raMutation(population, parent, ...)caretGA rfGA treebagGA
- number of possible predictors
- the population size passed into
- a binary matrix of the current subsets with predictors in columns and individuals in rows
- a vector of fitness values
- parent, parents
- integer(s) for which chromosomes are altered
- r, q, k
- tuning parameters for the specific selection operator
- not currently used
Most of the
gafs_* functions are based on those from the GA package by Luca Scrucca. These functions here are small re-writes to work outside of the GA package.
treebagGA are example lists that can be used with the
functions argument of
In the case of
... structure of
gafs passes through to the model fitting routine. As a consequence, the
train function can easily be accessed by passing important arguments belonging to
gafs. See the examples below. By default, using
caretGA will used the resampled performance estimates produced by
train as the internal estimate of fitness.
bagging functions are used directly (i.e.
train is not used). Arguments to either of these functions can also be passed to them though the
gafs call (see examples below). For these two functions, the internal fitness is estimated using the out-of-bag estimates naturally produced by those functions. While faster, this limits the user to accuracy or Kappa (for classification) and RMSE and R-squared (for regression).
The return value depends on the function.
Scrucca L (2013). GA: A Package for Genetic Algorithms in R. Journal of Statistical Software, 53(4), 1-37.
pop <- gafs_initial(vars = 10, popSize = 10) pop gafs_lrSelection(population = pop, fitness = 1:10) gafs_spCrossover(population = pop, fitness = 1:10, parents = 1:2) ## Not run: # ## Hypothetical examples # lda_ga <- gafs(x = predictors, # y = classes, # gafsControl = gafsControl(functions = caretGA), # ## now pass arguments to `train` # method = "lda", # metric = "Accuracy" # trControl = trainControl(method = "cv", classProbs = TRUE)) # # rf_ga <- gafs(x = predictors, # y = classes, # gafsControl = gafsControl(functions = rfGA), # ## these are arguments to `randomForest` # ntree = 1000, # importance = TRUE) # ## End(Not run)