trevorstephens / gplearn

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

Would there be a way to produce the equivalent Python code for the program coming from the symbolic regress or #287

Open c0def0x01 opened 1 year ago

c0def0x01 commented 1 year ago

Is there a way with gplearn to get the program provided by the symbolic regressor e.g. ˋsub(div(mul(X4, X12), div(X9, X9)), sub(div(X11, X12), add(X12, X0)))ˋ into an executable Python program e.g.

def prog(X0, X4, X9, X11, X12):
    return  … (X4 * X12) …

Would it be useful to enhance this in gplearn, or is there better ways to do this?

trevorstephens commented 1 year ago

Not really sure what is gained here? The whole package has the functionality to essentially execute the program via the .predict methods.

The closest might be to extract the underlying _Program objects and work with those directly. I don't have any plans at this stage to make those object accessible via a public API at this stage though.

If you just want to use the program later, you can export it: https://gplearn.readthedocs.io/en/stable/advanced.html#exporting