Transform str expression into tree #550
-
Is there any function, that allows to convert expression in a string form (ex: or May be there is another way to insert some function into a hall of fame ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Sorry, missed this one! Yes: from pysr import jl # Julia Main namespace
from pysr import PySRRegressor
from pysr import SymbolicRegression as SR # Backend library
# Create `.julia_options_`:
model = PySRRegressor(verbosity=0, max_evals=1)
model.fit([[1]], [1])
options = model.julia_options_
# Define operators for creating trees:
jl.options = options # Store `options` in Julia namespace
jl.seval("@extend_operators options") # Declare available operators
x1 = SR.Node(jl.Float32, feature=1) # If x is the first column (index 0 in Python)
# Store x1 in Julia namespace:
jl.x1 = x1
# Create equation from string:
eqn = jl.seval("x1 + 1") The To verify this is the correct equation, you can look at: SR.string_tree(eqn, options) which you can see is To get the score = ...
loss = ...
SR.PopMember(eqn, jl.Float32(score), jl.Float32(loss), options) which you can put in the hall of fame. |
Beta Was this translation helpful? Give feedback.
Sorry, missed this one!
Yes:
The
+
operator here gets mapped into an integer base…