R/evolve_model_cv.R
evolve_model_cv.Rd
evolve_model_cv
calls evolve_model
with varied numbers of
states and compares their performance with cross-validation.
evolve_model_cv(data, measure, k, actions, max_states, seed, popSize, pcrossover, pmutation, maxiter, run, parallel, verbose, ntimes)
data | A |
---|---|
measure | Optional length one character vector that is either:
"accuracy", "sens", "spec", or "ppv". This specifies what measure of
predictive performance to use for training and evaluating the model. The
default measure is |
k | Optional numeric vector length one only relevant if cv==TRUE, specifying number of folds for cross-validation. |
actions | Optional numeric vector with the number of actions. If not provided, then actions will be set as the number of unique values in the outcome vector. |
max_states | Optional numeric vector length one only relevant if
|
seed | Optional numeric vector length one. |
popSize | Optional numeric vector length one specifying the size of the GA population. A larger number will increase the probability of finding a very good solution but will also increase the computation time. This is passed to the GA::ga() function of the GA package. |
pcrossover | Optional numeric vector length one specifying probability of crossover for GA. This is passed to the GA::ga() function of the GA package. |
pmutation | Optional numeric vector length one specifying probability of mutation for GA. This is passed to the GA::ga() function of the GA package. |
maxiter | Optional numeric vector length one specifying max number of
iterations for stopping the GA evolution. A larger number will increase the
probability of finding a very good solution but will also increase the
computation time. This is passed to the GA::ga() function of the GA
package. |
run | Optional numeric vector length one specifying max number of consecutive iterations without improvement in best fitness score for stopping the GA evolution. A larger number will increase the probability of finding a very good solution but will also increase the computation time. This is passed to the GA::ga() function of the GA package. |
parallel | Optional logical vector length one. For running the GA evolution in parallel. Depending on the number of cores registered and the memory on your machine, this can make the process much faster, but only works for Unix-based machines that can fork the processes. |
verbose | Optional logical vector length one specifying whether helpful messages should be displayed on the user's console or not. |
ntimes | Optional integer vector length one specifying the number of times to estimate model. Default is 1 time. |
Returns the number of states that maximizes the measure
, e.g.
accuracy.
Luca Scrucca (2013). GA: A Package for Genetic Algorithms in R. Journal of Statistical Software, 53(4), 1-37. URL https://www.jstatsoft.org/v53/i04/.
Hastie, T., R. Tibshirani, and J. Friedman. (2009). The Elements of Statistical Learning: Data Mining, Inference, and Prediction, Second Edition. 2nd ed. New York, NY: Springer.