rankFeatures | R Documentation |
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.
rankFeatures(X, y, clf, pop, featEval)
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 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 |
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.
A numeric vector 'featEval', with updated values reflecting the average fitness scores of models that include each feature.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.