Question

I apply GP in pyevolve to train and it gives me the best tree. I would like to use this tree to test different data. I want to keep min is root of the tree, so the function will return -1 if gp_add, gp_mul... is the root of tree.

This is example about my best tree and the raw score is 1.0143

gp_min(gp_add(gp_mul(gp_min(a, b), c), d))

And this is the code, I try to apply the best individual in testing data.

bestIndi = ga.bestIndividual()
comp_code = bestIndi.getCompiledCode()
score = eval(comp_code)

Is this code on the right direction? Why the score is always -1?

Was it helpful?

Solution

That's on the right path. One main property in GP is the sufficiency property, which says the elements in the domain should be enough to solve the problem.

Check the range of your variables.

If want to keep min as the root of your tree it's preferable to apply that in the fitness function, however, if GP finds an individual better that one having the gp_min as the root then it would be preferable to eliminate that restriction.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top