evolve1 | R Documentation |
This function performs one cycle of evolution on a population, including evaluation, selection, crossover, and mutation steps, based on the specified classifier parameters. It returns the evolved population after these operations.
evolve1(X, y, clf, pop, featEval)
X |
A matrix or data frame of feature values, where each row represents a feature and each column represents a sample. |
y |
A response vector or target variable for supervised learning. The
length of |
clf |
A classifier object containing parameters for evolution, including options for crossover, mutation, and verbose output. |
pop |
A list representing the population, where each individual has attributes like 'fit_' for fitness. |
featEval |
A vector or list containing feature evaluation metrics, used in mutation to assess feature significance. |
The function first evaluates the fitness of the current population if it has not been done. It then selects the best individual and proceeds through the evolutionary steps:
1. **Evaluation**: If fitness values are missing, the population is evaluated. 2. **Selection & Crossover**: If crossover is enabled ('clf$params$cross'), parents are selected and crossover is performed to generate new individuals. 3. **Mutation**: If mutation is enabled ('clf$params$mutate'), some individuals are selected for mutation based on 'mutate_size', and mutations are applied using 'featEval'.
After each step, the population is re-evaluated, and the best individual is updated. If 'verbose' is enabled, details about the best individual are printed.
The evolved population list with updated individuals and fitness values.
## Not run:
X <- matrix(rnorm(100), nrow = 10) # Random features
y <- sample(c(0, 1), 10, replace = TRUE) # Random binary response
clf <- list(params = list(cross = TRUE, mutate = TRUE, mutate_size = 10, verbose = TRUE))
pop <- list(
list(fit_ = NA, indices_ = 1:5),
list(fit_ = NA, indices_ = 6:10)
)
featEval <- runif(10)
evolved_pop <- evolve1(X, y, clf, pop, featEval)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.