trevorstephens / gplearn

Genetic Programming in Python, with a scikit-learn inspired API
http://gplearn.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.59k stars 281 forks source link

Why is a large proportion of candidates in the initial population = None? #202

Closed nosb9124 closed 4 years ago

nosb9124 commented 4 years ago

Hello,

I am working through the example notebook https://github.com/trevorstephens/gplearn/blob/master/doc/gp_examples.ipynb and am able to reproduce the same results.

When I inspect the initial population est_gp._programs[0] only 139 candidates are a gplearn program and the remainder are None. I get similar results of a high proportion of the initial population being set to None when applying to my own regression problem. Why is this the case?

Line 222 of https://github.com/trevorstephens/gplearn/blob/master/gplearn/_program.py (I think this is the right place to look) implies this should never happen.

Thank you!

trevorstephens commented 4 years ago

Programs that did not make it through selection to contribute to the next generation are removed from the old generations due to the high memory use it causes, you can find the logic here: https://github.com/trevorstephens/gplearn/blob/master/gplearn/genetic.py#L502-L514

nosb9124 commented 4 years ago

Thanks!

trevorstephens commented 4 years ago

You're welcome :-)