ShuhuaGao / geppy

A framework for gene expression programming (an evolutionary algorithm) in Python
https://geppy.readthedocs.io/en/latest/
GNU Lesser General Public License v3.0
207 stars 76 forks source link

how to implement multigenes with different head length? #9

Closed grace9796 closed 5 years ago

grace9796 commented 5 years ago

Hi there, I'm trying use GEP to evolve trading rules(EDT-RNC) to detect buy/sell signal, but I have trouble in setting parameters. I've got four genes in one chromosome with length of different heads and RNC arrays. The example shows that fixed head length and rnc array. I'd like to ask for help that how should I rewrite the code of multigenes in the chromosome? Words are not enough to express my gratitude.

螢幕快照 2019-04-02 下午3 32 19
ShuhuaGao commented 5 years ago

Hi, you can try the class method of Chromosome Chromosome.from_genes here. To begin with, you need to create the four genes separately and assemble them into a list, which is the genes parameter of Chromosome.from_genes .

Is it necessary to use genes with various header lengths? Maybe you can set them all to the maximum value of the four. With different gene structures, it is not convenient to follow the toolbox style given in the examples. That is, you have to write your own code to breed individuals.

grace9796 commented 5 years ago

Another question for building EDT-RNC. The example in GEP_RNC_for_ML_with_UCI_Power_Plant_dataset is kind of regression problem. I'd like to ask how could I use geppy to practice as pic below (classification).

螢幕快照 2019-04-08 下午1 36 37
ShuhuaGao commented 5 years ago

Hi, there is nothing special about classification. Generally, we need to follow two steps in the evaluation function:

Thus, you mainly need to customize the evaluate function to meet your own need.