MilesCranmer / PySR

High-Performance Symbolic Regression in Python and Julia
https://ai.damtp.cam.ac.uk/pysr
Apache License 2.0
2.46k stars 217 forks source link

[Feature] Consider adding manual hint for initial population #163

Open evilmav opened 2 years ago

evilmav commented 2 years ago

Is your feature request related to a problem? Please describe. Let's say I have derived an analytic solution dependent on some parameters, while taking the others in -> 0 limit to be able to do so. Now I want to extend the solution for (small?) variation of the parameters assumed 0 previously. In this case it is probably more efficient to provide this initial solution manually and mutate from there, rather then starting with a totally random population. This is not only likely to save time, but also to find solution that converge to the known exact solution for the derived limit, which seems like a positive property.

Describe the solution you'd like Additional argument to fit() allowing to set the initial solution.

MilesCranmer commented 2 years ago

One approach to this is provide the analytic solution as an additional feature for PySR, then it can add adjustments to it, or re-scale it, or use it in operators.

However, this wouldn't let PySR modify the internals of the analytic solution (e.g., say it needed to adjust the argument of a sin(...) of an analytic solution). So in that case it would definitely help to have this feature.

PySR lets you start from a previous fit (warm_start=True) so you could also manually configure the state (stored in raw_julia_state_) to have the analytic solution in the initial population, but that requires some knowledge of the backend.

But, yes, it would be great to have this! Will need some modifications to the backend (https://github.com/MilesCranmer/SymbolicRegression.jl) to help randomly generate the population around a particular equation.