Home

APS
Downloads
Buy APS

Support
Register
Contact us

Knowledge Base of APS

Subscribe to the GEPList
 
Visit GEP

 

Choosing the Fitness Function

User Defined Fitness Functions
 
APS 3.0 comes equipped with 10 built-in fitness functions for classification problems and, most probably, you will find among them a suitable fitness function for your problem. But if you want to try other fitness functions to model your data, APS 3.0 allows you to design fitness functions of your own and use them to search the fitness landscape.

You can design your own fitness function using the Custom Fitness Function window.

For all classification problems, in order to be able to apply a particular fitness function, the learning algorithms APS 3.0 must convert the value returned by the evolved model into “1” or “0” using the 0/1 Rounding Threshold. If the value returned by the evolved model is equal to or greater than the rounding threshold, then the record is classified as “1”, “0” otherwise.

Thus, the 0/1 Rounding Threshold is an integral part of all fitness functions used for classification and must be appropriately set in the Settings Panel -> Fitness Function Tab.

The code for the custom fitness function must be in JavaScript and can be tested before evolving a model with it. Please remember that APS 3.0 uses fitness proportionate selection and, therefore, fitness must increase with performance and only non-negative values are acceptable. Below is the sample code of a correct fitness function, which is identical to the number of hits fitness function of APS 3.0.


     // All the values of the Target output
     // are accessible through the array:
     // aOutputTarget[0] = 0
     // aOutputTarget[1] = 1
     // aOutputTarget[2] = 0
     // etc.

     // All the values of the output of the Model
     // are accessible through the array:
     // aOutputModel[0] = 0
     // aOutputModel[1] = 1
     // aOutputModel[2] = 1
     // etc.

     // Essential and useful parameters you may use
     // to design your fitness function:
     // aParameters[0] = number of samples
     // aParameters[1] = averaged target output
     // aParameters[2] = variance of the target output
     // aParameters[3] = 0/1 rounding threshold
     // aParameters[4] = number of samples in the predominant class

     // Your custom fitness function must return a value, for example:
     // return fitness;

     // Below is an example of a correct fitness function, more specifically,
     // the Number of Hits fitness function of APS 3.0, for which 
     // the maximum fitness is equal to the number of sample cases:

     // NUMBER OF HITS
     var nSamples = aParameters[0];
     var roundingThreshold = aParameters[3];
     var fitness = 0.0;
     for (var i=0; i<nSamples; i++)
     {
          // Convert the value returned by the model into 1 or 0 
          if (aOutputModel[i] >= roundingThreshold)
          {
               aOutputModel[i] = 1;
          }
          else
          {
               aOutputModel[i] = 0;
          }
          // Evaluate fitness 
          if (aOutputModel[i] == aOutputTarget[i]) 
          {
               fitness++;
          }
     }

     // Exclude uninteresting models
     var limitViability = aParameters[4];
     if (fitness <= limitViability) 
     {
          fitness = 0;
     }

     return fitness;


Obviously, in this case, maximum fitness equals the number of samples in your data.

Home | Contents | Previous | Next