Data AnalysisOpen Source🔓 open source

PySR

Open-source symbolic regression tool that discovers compact mathematical equations from data — finds interpretable physical laws rather than black-box predictions, widely used in physics and astrophysics.

Last verified: July 2026

What it does

PySR (Python Symbolic Regression) searches for mathematical equations that describe a dataset. Given input variables and a target quantity, it finds an explicit formula — F = ma, E = mc², or a more complex but still interpretable expression — that fits the data well. The output is a human-readable equation, not a neural network’s internal weights.

Developed by Miles Cranmer (Princeton / Cambridge), PySR runs a multi-population evolutionary search: it combines, mutates, and selects symbolic expressions, guided by a trade-off between accuracy and complexity. It outputs a Pareto front of candidate equations — the best equation at each level of complexity — so you can choose between a simpler, less accurate expression and a more complex, more accurate one.

PySR has been used in astrophysics to discover relationships in galaxy survey data, in fluid dynamics, and as a tool for discovering candidate physical laws in domains where the theory is incomplete. It interfaces natively with Python (NumPy, PyTorch, JAX) and Julia.

Best for

Researchers who have data and want to find the underlying mathematical relationship, particularly when interpretability matters — you want an equation you can publish, analyse, and incorporate into physical theory, not a prediction from a model you can’t inspect. Most relevant in physics, astrophysics, fluid mechanics, and any field where the data-generating process might follow a compact mathematical law.

Pricing

Free and open-source (Apache 2.0 license). Available via pip install pysr.

Strengths

  • Outputs explicit, interpretable equations rather than black-box predictions — the result can be published, critiqued, and integrated into theory
  • Pareto front output lets you explicitly trade off between simplicity and accuracy — useful when you want the simplest equation that still fits the data
  • Scales to datasets with many variables and large sample sizes better than earlier symbolic regression approaches
  • Integrates with neural network workflows: SymbolicRegression.jl (the Julia backend) can be used in combination with neural nets to discover symbolic laws in learned representations (as in the “AI Feynman” approach)
  • Active development and community, with regular improvements to search efficiency

Limitations

  • Search space grows exponentially with the number of input variables — practical limits are roughly 5–10 variables for tractable search times
  • Can overfit: an equation that fits training data well may not generalize, especially with noisy data. Always test on held-out data.
  • Not guaranteed to find the true equation even if one exists — the evolutionary search is heuristic, not exhaustive
  • If the underlying relationship is not expressible as a compact equation (highly complex physical systems, emergent phenomena), symbolic regression won’t find it
  • Noisy data significantly degrades performance — works best when measurement noise is low relative to the signal

How it compares

vs. Key difference
Neural network regression Neural networks fit data more flexibly and accurately but produce black-box predictions; PySR produces interpretable equations at the cost of some fitting accuracy
Linear regression / polynomial fitting Linear and polynomial models assume a specific functional form; PySR searches freely over a space of operators and forms
Eureqa (discontinued) The most-used prior tool for symbolic regression; PySR is the active open-source successor with similar goals and improved scalability
AI Feynman A related approach that uses deep learning to preprocess data before symbolic regression; PySR is the more general-purpose, standalone tool