Home About Us Contact Search >>
Hits with Reward/Punishment Fitness Function  
Products Buy Now Downloads Support
 
 

Hits with Reward/Punishment Fitness Function

The JavaScript implementation of the Hits with Reward/Punishment fitness function is shown below. It is an example of a valid Custom Fitness Function of GeneXproTools 4.3. You can try it using the demo of GeneXproTools.

 
// 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 Model output
// 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 records
// aParameters[1] = averaged target output
// aParameters[2] = variance of the target output
// aParameters[4] = number of samples in the predominant class (function output 0 or 1)
// aParameters[5] = minimum program size
// aParameters[6] = maximum program size

// Useful information about the evolving models
// you may use to design your fitness function:
// aModelInfo[0] = program size
// aModelInfo[1] = used variables
// aModelInfo[2] = number of literals

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

// Below is an example of a correct fitness function, more specifically,
// the Hits with Punishment fitness function of GeneXproTools, for which 
// the maximum fitness is equal to 1000:

// HITS WITH PUNISHMENT/REWARD
var nRecords = aParameters[0];
var roundingThreshold = aParameters[3];
var fitness = 0.0;
var hits = 0; 
var fitnessHits = 0.0; 
var reward = 1.0; // must be greater than zero 
var punishment = -2.0; // is usually a negative value
var rewardPunishmentBallance = 0.0;
var truePositives = 0;
var trueNegatives = 0;
for (var nR=0; nR<nRecords; nR++)
{
    // Evaluation of the fitness components
    if (aOutputModel[nR] == aOutputTarget[nR])                   
    {
        hits++;
        rewardPunishmentBallance = rewardPunishmentBallance + reward;
        if(aOutputTarget[nR] == 1) 
        {
            truePositives++;
        }
        else
        {
            trueNegatives++;
        }
    }
    else
    {
        rewardPunishmentBallance = rewardPunishmentBallance + punishment;
    }
} //for nR
    
// Fitness evaluation & normalization
// Fitness from Punishments/Rewards
if (rewardPunishmentBallance < 0.0) rewardPunishmentBallance = 0.0;
rewardPunishmentBallance = rewardPunishmentBallance / (nRecords * reward);
    
// Fitness from Hits
fitnessHits = hits / nRecords;
    
// Final fitness
fitness = ((fitnessHits + rewardPunishmentBallance)/2.0) * 1000.0; 
    
// Death Penalty
if ((truePositives == 0) || (trueNegatives == 0))
{
    fitness = 0.0;
}
    
return fitness;
 

Download a free trial of GeneXproTools
 
 
GeneXproTools  

   


GeneXproServer  


Tutorials


Quick Tour Videos




Gene Expression Programming


   Subscribe to the GEP-list
Enter 2 + 32 =
Signup Now

“Finally, a world class user interface in the field of genetic programming and evolutionary computation !! GeneXproTools is simply unrivaled in its marvelous user interface, the breadth of its Fitness Functions, the choice and flexibility in Math and Logic functions, the clarity of its final Model Presentation, and a built in panel for Scoring new data, right inside the interface. This kind of functionality and ease of use has never been seen before in the field of Genetic Programming. Additionally, Dr Ferreira’s specific methodology of Gene Expression Programming makes important contributions to the field of evolutionary computation, and the various algorithms she has developed and deployed inside of GeneXproTools are brilliantly conceived, and her methodologies evolve highly predictive models that solve real business problems. GeneXproTools is an extraordinary structural tour de force.“

Brian C. Watt, CRM
Chief Risk Officer
Chief Financial Officer
GECC Inc, USA
   
 

More

 
 
 
 
[an error occurred while processing this directive]