crossingIndividual_v2: Create a New Individual by Combining Gene Vectors from Two...

View source: R/terga2.lib.R

crossingIndividual_v2R Documentation

Create a New Individual by Combining Gene Vectors from Two Parents

Description

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.

Usage

crossingIndividual_v2(X, y, clf, parent1, parent2)

Arguments

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 y should match the number of columns in X.

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.

Details

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.

Value

A list representing the new individual, with a gene vector created by combining and adjusting genes from both parents.

Examples

## 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)


predomics/predomicspkg documentation built on Dec. 11, 2024, 11:06 a.m.