selectIndividualToKeep | R Documentation |
This function selects the best individual from a population for each specified sparsity level, based on fitness. It groups individuals by their sparsity, then identifies the highest-ranking individual in each group.
selectIndividualToKeep(clf, pop)
clf |
A classifier object containing parameters for selection, including 'sparsity', which defines the target sparsity levels. |
pop |
A list representing the population, where each individual has attributes like 'eval.sparsity' (sparsity level) and 'fit_' (fitness score). |
The function first groups individuals in 'pop' by their sparsity levels, as specified in 'clf$params$sparsity'. For each group, it selects the individual with the highest fitness score ('fit_'). Only sparsity levels with at least one individual in the population are considered.
This approach allows for maintaining a diverse set of individuals across different sparsity levels, focusing on the best-performing individual within each sparsity category.
A list of the best individuals for each sparsity level specified in 'clf$params$sparsity', selected based on fitness.
## Not run:
pop <- list(
list(eval.sparsity = 3, fit_ = 0.9),
list(eval.sparsity = 4, fit_ = 0.8),
list(eval.sparsity = 3, fit_ = 0.85)
)
clf <- list(params = list(sparsity = c(3, 4, 5)))
best_individuals <- selectIndividualToKeep(clf, pop)
print(best_individuals)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.