fitnessEvolution: Get the evolution of the fitness

View source: R/fitness.R

fitnessEvolutionR Documentation

Get the evolution of the fitness

Description

Get the fitness of the best / average chromosomes after each generation

Usage

fitnessEvolution(
  object,
  what = c("mean", "best", "std.dev"),
  type = c("true", "raw")
)

Arguments

object

The GenAlg object returned by genAlg

what

can be one ore more of "best" (to return the fitness of the best chromosome for each generation), "mean" (to return the arithmetic mean fitness during each generation), and "std.dev" (for the standard deviation of the fitness values in each generation).

type

one of "true" or "raw". raw means the raw fitness value used within the GA, while true tries to convert it to the standard error of prediction (like fitness). If the standard deviation (what = "std.dev") is requested, the type will always be raw.

Details

Returns the progress of the fitness of the best or average chromosome.

Value

A vector with the best or average fitness value after each generation

Examples

ctrl <- genAlgControl(populationSize = 100, numGenerations = 15, minVariables = 5,
    maxVariables = 12, verbosity = 1)

evaluator <- evaluatorPLS(numReplications = 2, innerSegments = 7, testSetSize = 0.4,
    numThreads = 1)

# Generate demo-data
set.seed(12345)
X <- matrix(rnorm(10000, sd = 1:5), ncol = 50, byrow = TRUE)
y <- drop(-1.2 + rowSums(X[, seq(1, 43, length = 8)]) + rnorm(nrow(X), 1.5));

result <- genAlg(y, X, control = ctrl, evaluator = evaluator, seed = 123)

fitness(result) # Get fitness of the found subsets

h <- fitnessEvolution(result) # Get average fitness as well as the fitness of the
                              # best chromosome for each generation (at raw scale!)

plot(h[, "mean"], type = "l", col = 1, ylim = c(-7, -1))
lines(h[, "mean"] - h[, "std.dev"], type = "l", col = "gray30", lty = 2)
lines(h[, "mean"] + h[, "std.dev"], type = "l", col = "gray30", lty = 2)
lines(h[, "best"], type = "l", col = 2)

gaselect documentation built on Feb. 16, 2023, 6:14 p.m.