mutate2 | R Documentation |
This function performs mutation on a selected subset of individuals in a population, using feature evaluations to guide mutation decisions. It returns the mutated population.
mutate2(X, y, clf, pop, selection, 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 mutation, including 'size_world' (total number of genes) and 'parallel.local' (to enable parallel computation). |
pop |
A list representing the population, where each individual has attributes relevant to mutation. |
selection |
A vector of indices representing the individuals in 'pop' that should be mutated. |
featEval |
A numeric vector of feature evaluation scores, which will be updated to reflect the mutation's effect on feature importance. |
The 'mutate2' function first ranks features using 'rankFeatures', updating 'featEval' based on model fitness in the population. It then iterates over the selected individuals ('selection'), applying mutation to each. If parallel processing is enabled ('clf$params$parallel.local'), mutations are performed concurrently.
The mutation process uses the classifier's 'mutator' function to alter gene indices or coefficients in each selected individual based on feature evaluation probabilities.
A list representing the mutated population, with the individuals in 'selection' modified according to mutation operations.
## 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(size_world = 10, parallel.local = FALSE),
functions = list(mutator = mutator_v1))
pop <- list(
list(indices_ = c(1, 3, 5), fit_ = 0.8),
list(indices_ = c(2, 4, 6), fit_ = 0.7)
)
selection <- 1:2
featEval <- rep(0, 10)
mutated_pop <- mutate2(X, y, clf, pop, selection, featEval)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.