Define Multiple Outputs with TemplateExpressionSpec #1002
-
Hello, I would like to define TemplateExpressionSpec for two different outputs with coupled parameters. For instance, with
What would I add here to define templates for both outputs?
Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
You can set it up so that you pass template = TemplateExpressionSpec(
expressions=["f",],
variable_names=["x_0", "y_0", "y_1"],
parameters={"p": 2}
combine="""
A, n = p[1], p[2]
y_0_predicted = A * x_0 ^ n
y_1_predicted = A * x_0 - n
(y_0 - y_0_predicted)^2 + (y_1 - y_1_predicted)^2
"""
) then, your PySRRegressor would have a custom loss that simply returns the predicted model = PySRRegressor(
expression_spec=template,
elementwise_loss="my_custom_loss(predicted, target) = predicted"
)
model.fit(X, np.zeros(len(X))) and pass y_0 and y_1 as the 2nd and 3rd columns of X basically. And then simply pass whatever for |
Beta Was this translation helpful? Give feedback.
-
I have since put up an example here: https://ai.damtp.cam.ac.uk/pysr/examples/#13-vector-valued-expressions |
Beta Was this translation helpful? Give feedback.
You can set it up so that you pass
y_0
andy_1
as features, and have the template returns the per-row loss:then, your PySRRegressor would have a custom loss that simply returns the predicted
and pass y_0 and y_1 as the 2nd a…