population2: Generate and Initialize a Population for Evolutionary...

View source: R/terga2.lib.R

population2R Documentation

Generate and Initialize a Population for Evolutionary Computation

Description

This function generates an initial population of individuals for evolutionary algorithms, potentially using predefined parameters and sources, and evaluates their fitness.

Usage

population2(X, y, clf, featEval = NULL)

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 that includes parameters for generating and evaluating individuals. Expected to contain 'params' and possibly 'coeffs_' elements.

featEval

An optional named vector of feature evaluation metrics. If NULL, an NA-filled vector will be created with the same names as the row names of X.

Details

The function initializes an evolutionary population by creating individuals based on signs, injecting predefined individuals (if specified), loading additional individuals from files, and generating new individuals with random or specific feature models. After generation, the function evaluates and sorts the population based on fitness.

Value

A list representing the initialized and evaluated population, sorted by fitness. Returns NULL if the population fails to meet validity checks.

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(randomSigns = FALSE, language = "bin", size_pop_random = 5, parallel.local = FALSE, in_pop = "NULL", popSourceFile = "NULL", verbose = TRUE, evolve_k1 = FALSE))
pop <- population2(X, y, clf)

## End(Not run)


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