Revisiting Symbolic regression with "conditional constants" (#521) #904
-
Thank you for developing pySR! I am facing the problem as described in #521 asked by @mkellerressel . Specifically, the problem is to learn an equation that has two types of inputs, numeric (x) and categorical (i). I want a single equation where the constants ( In the responses there where three suggestions: Any thoughts or pointers would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
The latest PySR which came out some time after those previous responses has a feature dedicated for this! Check out spec = TemplateExpressionSpec(
expressions=["f", "g"],
variable_names=["x1", "x2", "class"],
parameters={"p1": 3, "p2": 3},
combine="p1[class] * sin(f(x1, x2)) + p2[class]",
)
model = PySRRegressor(expression_spec=spec)
model.fit(X, y) In this example, the third column of We also prescribe the specific form they are used. But you can also just write down combine="f(x1, x2, p1[class], p2[class])" and it is like your expression |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
The latest PySR which came out some time after those previous responses has a feature dedicated for this! Check out
TemplateExpressionSpec
, specifically with theparameters
option: https://ai.damtp.cam.ac.uk/pysr/examples/#11-expression-specifications:In this example, the third column of
X
is the categorical feature, and the first two are regular features.We also prescribe the specific form they are used. But you can also just write down