rankFeatures: Rank Features Based on Model Fitness

View source: R/terga2.lib.R

rankFeaturesR Documentation

Rank Features Based on Model Fitness

Description

This function evaluates and ranks features in the population based on their presence in individual models and their associated fitness scores. It updates a feature evaluation metric ('featEval') to reflect the average fitness of models in which each feature appears.

Usage

rankFeatures(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 evaluation, including 'evalToFit', which specifies the fitness attribute in each model.

pop

A list representing the population, where each individual model contains 'indices_' (genes or features used in the model) and 'fit_' (fitness score).

featEval

A numeric vector of feature evaluation scores, where each element corresponds to a feature in X. This vector is updated based on the average fitness of models that include each feature.

Details

The function iterates over each model in the population ('pop') and each feature (gene) in the model. For each feature, it updates 'featEval' by averaging the current feature score with the fitness score of the model in which it appears. The result is an updated ranking of features based on their presence in high-fitness models.

The function checks for negative values in 'featEval' and raises an error if any are found, as negative values indicate an issue in the evaluation process.

Value

A numeric vector 'featEval', with updated values reflecting the average fitness scores of models that include each feature.

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(evalToFit = "fit_"))
pop <- list(
  list(indices_ = c(1, 3, 5), fit_ = 0.8),
  list(indices_ = c(2, 4, 6), fit_ = 0.7)
)
featEval <- rep(0, 10)
updatedFeatEval <- rankFeatures(X, y, clf, pop, featEval)

## End(Not run)


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