evolve1: Evolve a Population in an Evolutionary Algorithm

View source: R/terga2.lib.R

evolve1R Documentation

Evolve a Population in an Evolutionary Algorithm

Description

This function performs one cycle of evolution on a population, including evaluation, selection, crossover, and mutation steps, based on the specified classifier parameters. It returns the evolved population after these operations.

Usage

evolve1(X, y, clf, pop, featEval)

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 evolution, including options for crossover, mutation, and verbose output.

pop

A list representing the population, where each individual has attributes like 'fit_' for fitness.

featEval

A vector or list containing feature evaluation metrics, used in mutation to assess feature significance.

Details

The function first evaluates the fitness of the current population if it has not been done. It then selects the best individual and proceeds through the evolutionary steps:

1. **Evaluation**: If fitness values are missing, the population is evaluated. 2. **Selection & Crossover**: If crossover is enabled ('clf$params$cross'), parents are selected and crossover is performed to generate new individuals. 3. **Mutation**: If mutation is enabled ('clf$params$mutate'), some individuals are selected for mutation based on 'mutate_size', and mutations are applied using 'featEval'.

After each step, the population is re-evaluated, and the best individual is updated. If 'verbose' is enabled, details about the best individual are printed.

Value

The evolved population list with updated individuals and fitness values.

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(cross = TRUE, mutate = TRUE, mutate_size = 10, verbose = TRUE))
pop <- list(
  list(fit_ = NA, indices_ = 1:5),
  list(fit_ = NA, indices_ = 6:10)
)
featEval <- runif(10)
evolved_pop <- evolve1(X, y, clf, pop, featEval)

## End(Not run)


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