Replies: 1 comment
-
|
I think the right way to do this is via Take a look at, e.g., #1002 (comment) and other discussions about the template specs. It is arbitrary Julia code, and doesn't need to be differentiable. So technically you could do anything you want there! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi PySR team — thanks for the amazing library!
Use case (ODE / weak-form SR)
Instead of fitting pointwise y ≈ f(X), I want to learn an expression for f(Q, C) by minimizing a grouped, integral residual (weak form). For each trajectory g:
This avoids numerical differentiation of Q and is more robust for short, noisy trajectories.
Question 1 — custom loss API
Does PySR allow a custom objective that depends on X, y, and the candidate predictions yhat (here yhat = f(Q, C) evaluated at each sample), so that inside the loss I can:
group samples by trajectory (e.g., via a group_id column in X);
sort each group by time t;
integrate yhat along t (e.g., trapezoid rule) to approximate int f(Q, C) dt;
compare the cumulative integral to observed Q(t) - Q(t0) and sum squared residuals?
Concretely, is there a full_objective-style hook in PySR where the signature gives access to X, y, yhat (and optionally weights) so I can implement the above? If yes, what’s the recommended way to pass it from Python — e.g., a Julia function string, or a Python callback? A minimal example would be super helpful.
Question 2 — grouping / time columns
Any guidance on best practices for grouped losses? For example, if I pack columns as
X = [C_pol, C_eth, C_pg, Q_obs, t, group_id]is it OK that the loss uses t and group_id only for bookkeeping, while the expression itself only “sees” [Q_obs, C_pol, C_eth, C_pg] as variables?
Question 3 — operators & safe numerics
For physical robustness we often use safe atoms like log1p, protected division, etc. Is it correct that we can provide these via unary_operators / binary_operators and map them with extra_sympy_mappings / extra_torch_mappings for export? Any caveats when using such custom operators together with a custom objective?
Minimal pseudo-code (intended)
Notes: The above is pseudo-code to illustrate the desired API; I’m asking what the actual way is to implement such a grouped integral-residual objective in PySR.
Thanks a lot! Any pointers to documentation or examples for a trajectory-level (non-elementwise) objective in PySR would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions