crossingIndividual_v1: Create a New Individual by Crossing Genes from Two Parents

View source: R/terga2.lib.R

crossingIndividual_v1R Documentation

Create a New Individual by Crossing Genes from Two Parents

Description

This function generates a new individual by combining genes from two parent individuals. It samples a subset of genes from the parents' combined gene pool, with the child’s gene sparsity determined based on the parents' sparsity levels.

Usage

crossingIndividual_v1(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.

parent1

A list representing the first parent, which includes 'indices_' (genes) and 'eval.sparsity' (gene sparsity).

parent2

A list representing the second parent, also with 'indices_' and 'eval.sparsity'.

Details

The function combines the genes of 'parent1' and 'parent2' into a unique pool and selects a subset for the child. The child’s sparsity level is randomly determined based on the range between the two parents' 'eval.sparsity'. If the parents have identical sparsity, a subset is sampled within the parent's sparsity limit.

**Note**: The function currently has limitations and may need further development to handle edge cases and differing gene pools effectively.

Value

A list representing the new individual, with a subset of genes ('indices') inherited from the 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() # Placeholder for classifier settings
parent1 <- list(indices_ = c(1, 3, 5, 7), eval.sparsity = 4)
parent2 <- list(indices_ = c(2, 4, 6, 8), eval.sparsity = 4)
child <- crossingIndividual_v1(X, y, clf, parent1, parent2)
print(child)

## End(Not run)


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