Step operator #246
-
|
Hi, To do so in PySR, I wrote the following code: model = PySRRegressor(
model_selection="best",
binary_operators=["*", "+", "-", "/"],
unary_operators=["Mystep", "Mysign"],
extra_sympy_mappings={"Mystep": lambda x: 1 if x>0 else 0 if x<0 else 0.5,
"Mysign": lambda x: 1 if x>0 else -1 if x<0 else 0},
)But, it doesn't work! |
Beta Was this translation helpful? Give feedback.
Answered by
MilesCranmer
Jan 12, 2023
Replies: 1 comment 8 replies
-
|
Here's an implementation which might be what you're looking for: #125 Essentially you have to use |
Beta Was this translation helpful? Give feedback.
8 replies
Answer selected by
AKHCE
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's an implementation which might be what you're looking for: #125
Essentially you have to use
sympy.Piecewise, rather than Python'sif, in order to get a correct mapping tosympy