MilesCranmer / PySR

High-Performance Symbolic Regression in Python and Julia

Home Page:https://astroautomata.com/PySR

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to exclude translational constants from the learning process?

jstan15 opened this issue · comments

Hi Miles Cranmer,

Thank you again for developing this useful tool.

I have a question to ask about a parameter setting. Is there a way for me to exclude transnational constants from the PySR learning process completely, so that the optimised expressions do not contain any constant associated with the addition or subtraction operators? I read up the documentation but I could not figure out how to do this.

Thank you for your help!

Hi @jstan15,

Thanks, glad to hear you are finding it useful!

Currently there is no functionality for this type of constraint. The only constraints available are (1) setting the max complexity of an equation, and (2) setting an operator-specific max complexity, as explained here: https://pysr.readthedocs.io/en/latest/docs/options/#constraining-operator-complexity.

This particular type of constraint is probably too specific to include in the general package, but if you want, you could add it manually in this function: https://github.com/MilesCranmer/SymbolicRegression.jl/blob/d2dda8785b23bc37dcb68651683cd32d2ff537f8/src/CheckConstraints.jl#L49. If your constraint is violated, return false, otherwise, return true. This requires working directly on the equation data structure (defined here); you can see some examples for how to do this in this file: https://github.com/MilesCranmer/SymbolicRegression.jl/blob/master/src/EquationUtils.jl.

Cheers,
Miles

(Then, pass the “julia_project” argument to PySR to point to a local copy of the backend)