PySR icon indicating copy to clipboard operation
PySR copied to clipboard

Predefined function form

Open nice-mon opened this issue 4 years ago • 2 comments

Hi Miles,

In the regression process, can we pre-define a function form first, and let the regression start from this function? for example, If our objective function is x02 + 2.0*cos(x3) - 2.0 like example.py, that is simple, pysr can get the result quickly. however, In some research processes, our objective function may be more complicated, such as x02+(x1*x0)*exp(sin(x2)x1), At this time, pysr may take longer to optimize and may fall into a local optimal solution. so, So, I wonder if it is possible to predefine a function form in the pysr function, for example, x0exp(sin(x2)). Let the regression start from this function to speed up the efficiency of optimization. It is like applying a boundary condition to the solution equation.

thanks.

nice-mon avatar Mar 08 '21 14:03 nice-mon

Hi @nice-mon,

My recommendation for this, if you do know a common functional form, is to define this as a new feature. e.g., set x4=x0*exp(sin(x2)) before passing it.

The other option is to play with the constraints kwarg: https://pysr.readthedocs.io/en/latest/docs/options/#constraining-operator-complexity which I think can help with this. e.g., you could say that exp can only have complexity of at most 2 in its input, and maybe sin at most 1.

But in general, I would definitely expect PySR to find this function pretty easily with the right hyperparameters. Can you try re-running it with the future default hyperparameters listed here: https://github.com/MilesCranmer/PySR/issues/33? These hyperparameters are much better at avoiding local optima, partly because they turn off annealing.

Cheers! Miles

MilesCranmer avatar Mar 08 '21 21:03 MilesCranmer

Maybe adding a new constraint parameter saying how many times an operator can be used could help. Alternatively being able to specify complexity weights for each operator.

It would be useful for what I'm playing with.

RafaGago avatar Jul 20 '21 20:07 RafaGago