Learn R Programming

FSinR (version 1.0.8)

ga: Genetic Algorithm

Description

The ga method yang1998featureFSinR starts with an initial population of solutions and at each step applies a series of operators to the individuals in order to obtain new and better population of individuals. These operators are selection, crossing and mutation methods. This method uses the GA package implementation GAPkg1FSinR GAPkg2FSinR.

Usage

ga(
  data,
  class,
  featureSetEval,
  popSize = 20,
  pcrossover = 0.8,
  pmutation = 0.1,
  maxiter = 100,
  run = 100,
  verbose = FALSE
)

Arguments

data
  • A data frame with the features and the class of the examples

class
  • The name of the dependent variable

featureSetEval
  • The measure for evaluate features

popSize
  • The popuplation size

pcrossover
  • The probability of crossover between individuals

pmutation
  • The probability of mutation between individuals

maxiter
  • The number of iterations

run
  • Number of consecutive iterations without fitness improvement to stop the algorithm

verbose
  • Print the partial results in each iteration. This functionality is not available if the objective of the evaluation method is to minimize the target value (e.g. regression methods)

Value

A list is returned containing for each repetition of the algorithm:

bestFeatures

A vector with all features. Selected features are marked with 1, unselected features are marked with 0

bestFitness

Evaluation measure obtained with the feature selection

population

Matrix with the population of the last iteration of the algorithm along with the evaluation measure of each individual

References

Examples

Run this code
# NOT RUN {
## Genetic algorithm for iris dataset (filter method)
ga(iris, 'Species', roughsetConsistency, popSize = 10, maxiter=5, verbose=TRUE)
# }

Run the code above in your browser using DataLab