Description Usage Arguments Value Author(s) See Also Examples
These functions allow you to initialize (GenAlg
) and iterate
(newGeneration
) a genetic algorithm to perform feature
selection for binary class prediction in the context of gene
expression microarrays or other high-throughput technologies.
1 2 3 | GenAlg(data, fitfun, mutfun, context, pm=0.001, pc=0.5, gen=1)
newGeneration(ga)
popDiversity(ga)
|
data |
The initial population of potential solutions, in the form of a data matrix with one individual per row. |
fitfun |
A function to compute the fitness of an individual solution. Must take
two input arguments: a vector of indices into rows of the population
matrix, and a |
mutfun |
A function to mutate individual alleles in the population. Must take two
arguments: the starting allele and a |
context |
A list of additional data required to perform mutation or to compute
fitness. This list is passed along as the second argument when
|
pm |
A real value between |
pc |
A real value between |
gen |
An integer identifying the current generation. |
ga |
An object of class |
Both the GenAlg
generator and the newGeneration
functions
return a GenAlg-class
object. The popDiversity
function
returns a real number representing the average diversity of the population.
Here diversity is defined by the number of alleles (selected features) that
differ in two individuals.
Kevin R. Coombes krc@silicovore.com, P. Roebuck proebuck@mdanderson.org
GenAlg-class
,
GenAlg-tools
,
maha
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # generate some fake data
nFeatures <- 1000
nSamples <- 50
fakeData <- matrix(rnorm(nFeatures*nSamples), nrow=nFeatures, ncol=nSamples)
fakeGroups <- sample(c(0,1), nSamples, replace=TRUE)
myContext <- list(dataset=fakeData, gps=fakeGroups)
# initialize population
n.individuals <- 200
n.features <- 9
y <- matrix(0, n.individuals, n.features)
for (i in 1:n.individuals) {
y[i,] <- sample(1:nrow(fakeData), n.features)
}
# set up the genetic algorithm
my.ga <- GenAlg(y, selectionFitness, selectionMutate, myContext, 0.001, 0.75)
# advance one generation
my.ga <- newGeneration(my.ga)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.