Skip to content
Discussion options

You must be logged in to vote

You can set it up so that you pass y_0 and y_1 as features, and have the template returns the per-row loss:

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 a…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@janzenchoi
Comment options

@MilesCranmer
Comment options

@janzenchoi
Comment options

@MilesCranmer
Comment options

Answer selected by janzenchoi
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants