tag_select | R Documentation |
This function selects individuals in a population for evolutionary operations, including elite and random selection, pairing individuals for mating, and tagging some individuals for mutation. The selection process is based on specified percentages in the classifier object ('clf').
tag_select(X, y, clf, pop)
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 selection, including 'select_perc', 'select_percByMethod', 'size_pop', and 'mutate_size'. |
pop |
A list representing the population, where each individual has attributes including 'mate' and 'toBeMutated'. |
The function begins by sorting the population based on fitness ('fit_' attribute). It then calculates the number of individuals to be selected for mutation based on 'select_perc' in 'clf'. Selection is split into two methods, elite and random, as specified by 'select_percByMethod', and individuals are tagged for mating within these groups.
Following selection, individuals are paired for mating, with each selected individual having a 'mate' attribute set. The function then calls 'tag_ToBeMutated' to mark some individuals for mutation based on 'mutate_size' from 'clf'.
The modified population list, where selected individuals are tagged with 'mate' attributes for mating and 'toBeMutated' attributes for mutation.
## 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(select_perc = 50, select_percByMethod = c(30, 20), size_pop = 10, mutate_size = 10))
pop <- list(
list(fit_ = 0.9, mate = list(), toBeMutated = FALSE),
list(fit_ = 0.8, mate = list(), toBeMutated = FALSE),
# Add additional individuals as needed
)
pop <- tag_select(X, y, clf, pop)
# Check which individuals are selected for mating and mutation
sapply(pop, function(ind) ind$mate)
sapply(pop, function(ind) ind$toBeMutated)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.