individual_vec_v2: Generate a Sparse Individual Vector with Specified Density

View source: R/terga2.lib.R

individual_vec_v2R Documentation

Generate a Sparse Individual Vector with Specified Density

Description

This function generates an individual vector with a specific sparsity level, based on parameters defined in a classifier object ('clf'). It supports binary and ternary language configurations and allows for sign customization.

Usage

individual_vec_v2(clf, signs = NULL)

Arguments

clf

A classifier object that contains parameters for generating the vector, such as 'size_world', 'sparsity.min', 'sparsity.max', 'sparsity.mean', and 'language'.

signs

An optional vector of signs used to populate the individual vector at specified indices. If NULL, the function randomly assigns values based on the language setting in clf.

Details

The function constructs a vector of length 'clf$params$size_world' and assigns values based on either binary or ternary language, as specified in 'clf$params$language'. The sparsity level is controlled by 'sparsity.min' and 'sparsity.max', or by 'sparsity.mean' if the minimum and maximum sparsity levels are equal. If 'signs' is provided, it will populate the vector at selected indices.

If 'clf$params$size_world' is not set, a warning is issued (if warnings are enabled in 'clf') and the function returns NULL.

Value

A numeric vector of length 'clf$params$size_world' with elements set based on sparsity and language parameters. Returns NULL if 'size_world' is not properly set.

Examples

## Not run: 
clf <- list(params = list(language = "bin", size_world = 50, sparsity.mean = 10, sparsity.min = 5, sparsity.max = 15, warnings = TRUE))
individual <- individual_vec_v2(clf)

## End(Not run)


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