An initiative of the European Commission

PySR

Constrained symbolic regression for interpretable scientific equation discovery

Details

Practice contact

Miles Cranmer

Organisation(s)

University of Cambridge

Country

United Kingdom

Scientific Domain

Cross-domain

Context

Institutional Type

Research institute & Higher education institution

Data Governance

Dataset-dependent

Resource Conditions

Application-dependent

AI Use

PySR integrates symbolic regression into scientific analysis to discover compact mathematical expressions from numerical data. AI enters after researchers have defined the variables, observations or simulation outputs to be analysed and before a final scientific relationship is accepted. PySR uses a multi-population evolutionary search implemented through SymbolicRegression.jl to generate, simplify and optimise candidate equations, balancing predictive fit against expression complexity. Researchers specify the input variables and permissible mathematical operators and can also supply physical units. When units are provided, PySR can encourage dimensional consistency by penalising dimensionally inconsistent expressions rather than guaranteeing it. The output is a set of candidate symbolic expressions that approximate the relationship between inputs and an outcome. These expressions remain explicit mathematical objects, allowing researchers to inspect their structure and compare them with existing theory or domain knowledge. The AI therefore generates interpretable candidate relationships that can be evaluated on held-out data, against established models, and through physical, experimental or substantive plausibility checks before they are used in scientific interpretation.

Enabling Conditions

PySR was developed in response to a scientific need for symbolic-regression methods that could search large spaces of mathematical expressions efficiently enough for real research problems. Early methodological work in astrophysics provided a demanding use case: extracting interpretable analytic relationships from complex predictive models and simulation data. This created a practical requirement for symbolic regression that combined expressive search with computational efficiency and produced equations suitable for scientific interpretation.

Development was enabled by a hybrid software architecture. The search engine is implemented in Julia as SymbolicRegression.jl, while PySR provides a Python interface for researchers working in the scientific Python ecosystem. This combination supports high-performance evolutionary search while keeping the method accessible in established research workflows. Parallel population-based search, symbolic simplification and numerical optimisation of constants make large equation searches computationally feasible.

A further enabling condition was sustained open-source development around scientific requirements. PySR and SymbolicRegression.jl are both open-source packages released under the Apache 2.0 licence. The software supports configurable operators, complexity control, custom objectives, parallel execution and the use of physical units. When units are supplied, dimensional consistency can be encouraged through penalties on dimensionally inconsistent expressions rather than enforced as a guarantee. These capabilities allow the same core method to be adapted across disciplines without requiring research teams to redesign the symbolic-regression algorithm for each application. Benchmarking and reproducible examples have also supported implementation: the reference work introduced EmpiricalBench for testing recovery of empirical equations, while the documentation provides model settings and examples that researchers can adapt to their own data and validation workflows.

Outcomes

PySR has demonstrated value as a method for converting predictive relationships into explicit equations that can be inspected, compared and interpreted scientifically. Its reference paper introduced EmpiricalBench to test whether symbolic-regression systems can recover known empirical relationships from real and synthetic datasets, establishing evaluation around scientific equation recovery as well as prediction. Applications now span domains including astrophysics, gravitational-wave research, materials science and mathematical modelling, showing that the same AI method can be reused for different forms of numerical scientific data. A gravitational-wave application is provided by Wong and Cranmer (2022).

Published applications illustrate how the output can contribute to knowledge production. In a 2025 study of hybrid fibre-reinforced polymer bolted connections, Sorour et al. (2025) used PySR to derive an explicit equation for damage-initiation load from experimentally and numerically generated data. The equation was compared with conventional predictive models and with independent validation cases, and researchers interpreted its terms in relation to geometric and mechanical properties and examined sensitivity through symbolic derivatives. This type of workflow makes the AI output available for scientific scrutiny because the discovered relationship can be tested, differentiated, compared with established models and related to domain knowledge.

The principal methodological limitation is that a compact equation is not automatically a scientific law or causal mechanism. Results depend on the variables, operators, complexity penalties, constraints and data supplied to the search. Good practice therefore requires researchers to treat discovered expressions as candidate empirical models or hypotheses until they are supported by independent evidence. PySR supports this approach by returning multiple accuracy-complexity trade-offs instead of a single opaque prediction and by allowing scientific constraints to be encoded in the search. Its open implementation and cross-disciplinary reuse support transferability, while computational requirements remain adjustable through search settings and parallel execution.

Sources

PySR repository: https://github.com/astroautomata/PySR  

SymbolicRegression.jl: https://github.com/astroautomata/SymbolicRegression.jl

Documentation: https://pysr.ai/  

Cranmer, M. (2023). Interpretable Machine Learning for Science with PySR and SymbolicRegression.jl. arXiv:2305.01582. https://arxiv.org/abs/2305.01582

Cranmer, Miles, Alvaro Sanchez Gonzalez, Peter Battaglia, Rui Xu, Kyle Cranmer, David Spergel, and Shirley Ho. “Discovering symbolic models from deep learning with inductive biases.” Advances in neural information processing systems 33 (2020): 17429-17442. https://arxiv.org/abs/2006.11287  

Sorour, S.S., Saleh, C.A. & Shazly, M. Integrating machine learning and symbolic regression for predicting damage initiation in hybrid FRP bolted connections. Sci Rep 15, 18564 (2025). https://doi.org/10.1038/s41598-025-02390-4  

Wong, K.W. and Cranmer, M., 2022. Automated discovery of interpretable gravitational-wave population models. arXiv preprint arXiv:2207.12409. https://arxiv.org/abs/2207.12409

More applications: https://pysr.ai/papers

Similar Good Practices

  • Good Practices
  • AI Science Community
  • Interdisciplinary Cooperations
  • AI Research

SciMuse

AI-assisted generation and prioritisation of scientific research ideas

  • Good Practices
  • AI Science Community
  • Interdisciplinary Cooperations
  • AI Research

PySR

Constrained symbolic regression for interpretable scientific equation discovery

  • Good Practices
  • AI Science Community
  • Life Sciences
  • AI Research

AnatCL

Anatomical foundation models for brain MRIs

  • Good Practices
  • AI Science Community
  • Earth Sciences
  • AI Research

CY-Bench

A benchmark dataset for sub-national crop yield forecasting

  • Good Practices
  • AI Science Community
  • Interdisciplinary Cooperations
  • AI Research

cmbagent

Open-source Planning & Control language agents for autonomous scientific research

  • Good Practices
  • AI Science Community
  • Interdisciplinary Cooperations
  • AI Research

GROBID

Open-source machine learning for turning scholarly PDFs into structured research data

  • Good Practices
  • AI Science Community
  • Earth Sciences
  • AI Research

ESA WorldCover 2021

Machine-learning production and independent validation of a global land-cover map at 10 m resolution

  • Good Practices
  • AI Science Community
  • Materials Science
  • AI Research

Autoplex

Automatic tool to train and validate machine learning interatomic potentials.

  • Good Practices
  • AI Science Community
  • Social Science and Humanities 
  • AI Research

Transkribus

Сooperative AI platform for handwritten text recognition and layout analysis of historical documents

  • Good Practices
  • AI Science Community
  • Earth Sciences
  • AI Research

MLCast

Open-source community infrastructure for machine-learning weather nowcasting

  • Good Practices
  • AI Science Community
  • Interdisciplinary Cooperations
  • AI Research

SciMuse

AI-assisted generation and prioritisation of scientific research ideas

  • Good Practices
  • AI Science Community
  • Interdisciplinary Cooperations
  • AI Research

SuperCode

AI-assisted optimisation of scientific software for sustainable computing