Skip to content

How to get the equations for TemplateExpressionSpec and how to use it to define a custom objective function #865

Answered by MilesCranmer
cristinarg9 asked this question in Q&A
Discussion options

You must be logged in to vote
  1. Correct, template expressions do not support exporting to latex. (Let me know if you have any suggestions to make the error message a bit more clear? I wasn't sure how I could put this in an error message to make it clear that it is not supported.)
  2. For this I would add the additional labels as features:
beta_1 = 1.0  # SET ME
beta_2 = 2.0  # SET ME

template = TemplateExpressionSpec(
    expressions=["f", "g"],
    variable_names=["x1", "x2", "x3", "x4", "y_real", "f_real", "g_real"]
    parameters={"p": 2},
    combine=f"""
        f_predicted = f(x1, x2)
        g_predicted = g(x1, x3, x4)
        y_predicted = p[1] * f_predicted + p[2] * g_predicted
        
        (y_real - y_predi…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by cristinarg9
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@MilesCranmer
Comment options

@cristinarg9
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
PySR PySR-related discussion
2 participants