selectIndividualToKeep: Select the Best Individual by Sparsity Level from a...

View source: R/terga2.lib.R

selectIndividualToKeepR Documentation

Select the Best Individual by Sparsity Level from a Population

Description

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.

Usage

selectIndividualToKeep(clf, pop)

Arguments

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).

Details

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.

Value

A list of the best individuals for each sparsity level specified in 'clf$params$sparsity', selected based on fitness.

Examples

## 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)


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