Wave 10 — rigor & sharing: CLI — lawsynth backtest (rolling-origin/walk-forward: N origins x horizon, per-state RMSE/MAE/R2 + skill-vs-horizon decay + verdict, --html report); lawsynth workspace export/import (portable .lsworkspace archive: world bytes + provenance + runs, per-entry SHA-256 integrity, non-destructive import). SDK — Study.backtest -> Backtest (skill-vs-horizon decay, deterministic); lawsynth.Project workspace persisting in the CLI library.tsv format (verified bidirectional CLI<->SDK interop) with export/import archives. Docs — a real cookbook (10 task recipes, CLI + SDK each) + 3 end-to-end tutorials, verified against the shipped source (two-intervention-semantics and preset-vs-recipe differences called out). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
4.1 KiB
Pick the right settings per domain
Goal: get a sensible result without learning every knob. A preset (CLI) or recipe (SDK) seeds a bundle of discovery settings tuned for a family of systems. Explicit flags/overrides always win.
CLI presets
List them:
lawsynth presets
Expected shape:
Discovery presets (use with `discover --preset <name>`):
physics (alias: mechanics)
Oscillatory & mechanical systems (polynomial + trig features)
tunes: polynomial degree 3; trigonometric features on (sin/cos); sparse threshold 0.05
suits: pendulum, van-der-pol
ecology
Predator-prey & logistic interactions (quadratic cross terms)
tunes: polynomial degree 2 (bilinear x*y interactions); sparse threshold 0.02
suits: lotka-volterra
epidemiology
...
finance
...
general
...
Explicit flags (e.g. --degree, --threshold) always override the preset.
Apply a preset with --preset, then override any single knob:
# ecology: quadratic library, low threshold to keep small interaction terms
lawsynth discover prey.csv --time time --state x,y --output prey.lsworld \
--preset ecology
# physics: cubic + trig — for oscillators/pendulums
lawsynth new pendulum --data pend.csv
lawsynth discover pend.csv --time time --state theta,omega --output pend.lsworld \
--preset physics
# start from a preset, then override just the threshold
lawsynth discover prey.csv --time time --state x,y --output prey.lsworld \
--preset ecology --threshold 0.01
Available preset names (incl. aliases): ecology, epidemiology, finance,
general, mechanics, physics.
SDK recipes
import lawsynth
lawsynth.recipes.names() # ('mechanics', 'ecology', 'epidemiology', 'finance', 'general')
print(lawsynth.recipes.get("ecology").describe())
Expected shape of .describe():
Recipe: ecology
A quadratic library capturing pairwise species interactions ...
Suited to: Lotka–Volterra predator–prey, competitive Lotka–Volterra, ...
Discovery settings (differences from defaults):
derivative_method = 'finite'
polynomial_degree = 2
solver = 'stlsq'
threshold = 0.05
Explicit overrides passed to discover() always win.
Apply a recipe on a study; layer overrides on top:
study = lawsynth.Study.from_csv("prey.csv", time="time", state=["x", "y"])
result = study.discover(recipe="ecology") # curated defaults
result = study.discover(recipe="mechanics", threshold=0.02) # override wins
recipe and an explicit config= are mutually exclusive (a recipe is a
starting config); **overrides always win over either.
Domains at a glance
| Domain | CLI preset (--preset) |
SDK recipe (recipe=) |
|---|---|---|
| Mechanics / oscillators | physics (alias mechanics): degree 3, trig on, threshold 0.05 |
mechanics (alias physics): degree 3, threshold 0.05, stlsq |
| Ecology / predator-prey | ecology: degree 2, threshold 0.02 |
ecology: degree 2, threshold 0.05, stlsq |
| Epidemiology / compartments | epidemiology: degree 2, threshold 0.02 |
epidemiology: degree 2, threshold 0.01, stlsq |
| Finance / rates | finance: degree 3, rational on, refine on |
finance: degree 2, threshold 0.02, sr3 solver |
| Unknown | general: degree 2, threshold 0.05 |
general: degree 2, threshold 0.05, stlsq |
Presets and recipes are tuned independently and do not match knob-for-knob. Notably, the CLI
physicspreset turns trigonometric features on, but the SDKmechanicsrecipe does not — for a pendulum in the SDK, add the toggle:study.discover(recipe="mechanics", include_trigonometric=True)Likewise the CLI
financepreset usesstlsq+ rational + refinement, while the SDKfinancerecipe uses thesr3solver. Pick the surface, read what it tunes (lawsynth presets/recipes.get(name).describe()), and override as needed.
See also
- Discover from a CSV for the base loop.
- Take your model elsewhere once you're happy with the fit.