Fitness function for times series prediction problem

Namespace:  AForge.Genetic
Assembly:  AForge.Genetic (in AForge.Genetic.dll) Version: 2.2.4.0 (2.2.4.0)

Syntax

C#
public class TimeSeriesPredictionFitness : IFitnessFunction

Remarks

The fitness function calculates fitness value of GP and GEP chromosomes with the aim of solving times series prediction problem using sliding window method. The fitness function's value is computed as:

CopyC#
100.0 / ( error + 1 )
where error equals to the sum of absolute differences between predicted value and actual future value.

Sample usage:

CopyC#
// number of points from the past used to predict new one
int windowSize = 5;
// time series to predict
double[] data = new double[13] { 1, 2, 4, 7, 11, 16, 22, 29, 37, 46, 56, 67, 79 };
// constants
double[] constants = new double[10] { 1, 2, 3, 5, 7, 11, 13, 17, 19, 23 };
// create population
Population population = new Population( 100,
new GPTreeChromosome( new SimpleGeneFunction( windowSize + constants.Length ) ),
new TimeSeriesPredictionFitness( data, windowSize, 1, constants ),
new EliteSelection( ) );
// run one epoch of the population
population.RunEpoch( );

Inheritance Hierarchy

System..::.Object
  AForge.Genetic..::.TimeSeriesPredictionFitness

See Also