crossingIndividual_v2 | R Documentation |
This function generates a new individual by combining dense gene vectors from two parent individuals. It applies sparsity control to ensure the child’s gene vector meets specified minimum and maximum sparsity constraints.
crossingIndividual_v2(X, y, clf, parent1, parent2)
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 generating a new individual, including 'sparsity.min' and 'sparsity.max' to control sparsity. |
parent1 |
A list representing the first parent, containing attributes necessary for obtaining a dense gene vector. |
parent2 |
A list representing the second parent, also containing attributes necessary for obtaining a dense gene vector. |
The function creates a dense gene vector ('child') by taking half of the gene vector from 'parent1' and half from 'parent2'. After combining, it applies sparsity control:
- **If the child’s sparsity is below the minimum** (‘sparsity.min'), additional genes are randomly added from the parents’ combined gene reservoir until the minimum sparsity is reached. - **If the child’s sparsity exceeds the maximum** ('sparsity.max'), excess genes are randomly removed until the sparsity meets the maximum threshold.
This approach ensures that the child’s gene vector adheres to the specified sparsity constraints, creating a balanced and controlled gene distribution.
A list representing the new individual, with a gene vector created by combining and adjusting genes from both parents.
## 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(sparsity.min = 3, sparsity.max = 6))
parent1 <- list() # Placeholder, assuming `individualGetDenseVec` can process this
parent2 <- list() # Placeholder, assuming `individualGetDenseVec` can process this
child <- crossingIndividual_v2(X, y, clf, parent1, parent2)
print(child)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.