mutator_v1 | R Documentation |
This function mutates a specified individual's genes by altering a subset of them according to a defined mutation rate and gene reservoir.
mutator_v1(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 'mutate_rate' and 'size_world'. |
pop |
The current population list, used as context for the mutation but not directly modified by this function. |
individual_to_be_mutated |
A list representing the individual to be mutated, with attributes 'eval.sparsity' (sparsity level) and 'indices_' (genes). |
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 the mutation. |
The function calculates the number of genes to mutate ('perc') based on the individual’s sparsity level and the mutation rate defined in 'clf'. If the number of genes to mutate exceeds the available gene reservoir, the mutation rate is adjusted accordingly. Genes for mutation are chosen from ‘all_genes' and replaced in the individual’s genome.
The mutation process includes: - Calculating mutation degree based on mutation rate and sparsity. - Selecting genes for mutation and replacing them with new genes from the reservoir.
A mutated individual list, 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(mutate_rate = 20, size_world = 100))
individual_to_be_mutated <- list(eval.sparsity = 5, indices_ = sample(1:100, 5))
all_genes <- 1:100
featEval <- runif(10)
mutated_individual <- mutator_v1(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.