mutator_v2 | R Documentation |
This function mutates a specified individual's genes, choosing mutation actions based on feature evaluation probabilities rather than a fixed mutation rate. Actions include modifying, adding, or removing genes, depending on mutation conditions and individual sparsity.
mutator_v2(X, y, clf, pop, individual_to_be_mutated, all_genes, 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 'current_seed', 'language', and 'sparsity'. |
pop |
The current population list, used as context for mutation but not directly modified by this function. |
individual_to_be_mutated |
A list representing the individual to mutate, with attributes 'indices_' (genes) and 'coeffs_' (gene coefficients). |
all_genes |
A vector of all possible gene indices, representing the complete set of genes that could be selected during mutation. |
featEval |
A vector or list of feature evaluation metrics, used to guide mutation probabilities for selecting features. |
The mutation process is guided by 'featEval', which assigns a probability for each feature to be selected for mutation based on its evaluation score. The mutation action is chosen based on the individual’s sparsity and classifier settings:
- **Modify**: Inverts the coefficient of a randomly selected gene within the individual. - **Add**: Adds a new gene to the individual, drawn from 'all_genes' based on feature evaluation probabilities. - **Remove**: Deletes a randomly selected gene from the individual.
The mutation action is determined based on the individual’s current sparsity and the classifier's settings. If no suitable genes remain for mutation, the function returns the individual unchanged.
A mutated individual list with updated 'indices_' and 'coeffs_', representing the modified genome of the input individual.
## 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(current_seed = 42, language = "ternary", sparsity = c(5, 10)))
individual_to_be_mutated <- list(indices_ = sample(1:100, 5), coeffs_ = rep(1, 5))
all_genes <- 1:100
featEval <- runif(10)
mutated_individual <- mutator_v2(X, y, clf, pop = NULL, individual_to_be_mutated, all_genes, featEval)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.