pysr
Simple and efficient symbolic regression
What it is and what it does
PySR is a symbolic regression tool that discovers interpretable mathematical expressions fitting your data. Instead of returning a neural network or opaque model, it uses evolutionary search powered by Julia to explore the space of possible equations, combining operators like addition, multiplication, and functions like cosine or exponential. It follows scikit-learn's fit/predict interface, making it familiar to data scientists while offering something fundamentally different: equations you can read, understand, and use analytically.
The package is designed for low-dimensional datasets where interpretability matters more than squeezing out the last percentage point of accuracy. It also supports symbolic distillation—converting trained neural networks into analytic equations—which can help explain deep learning models. Configuration is extensive: you define which operators to search, custom loss functions, complexity penalties, and iteration counts, giving you fine control over the search process.
Use it for:
- Discover interpretable formulas from experimental physics or chemistry data where understanding the equation matters as much as prediction.
- Convert a trained neural network into a symbolic equation for scientific interpretation or deployment in resource-constrained environments.
- Fit low-dimensional datasets where you suspect a simple closed-form relationship exists but don't know its structure.
- Generate candidate equations for hypothesis testing in scientific research where the model itself is the research output.
- Reduce model complexity and improve generalization by finding sparse, parsimonious expressions instead of high-degree polynomials.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PySR searches for symbolic expressions that fit data by combining genetic algorithms with Julia's performance, returning human-readable equations instead of black-box models.
Yes, if you work with low-dimensional data where interpretability is a priority or you need to extract equations from neural networks. The active maintenance, permissive license, low install friction, and scikit-learn-compatible interface make it a solid choice. Not recommended if you need black-box performance on high-dimensional datasets or require guaranteed convergence to a global optimum.
Install
pysr on PyPI
pip
pip install pysruv
uv add pysrpoetry
poetry add pysrInstalling pysr
Before you install
Low friction install with a pure Python wheel; Julia dependencies install automatically on first import. Actively maintained with recent releases.
License in practice
Apache 2.0 permissive license allows commercial and private use with minimal restrictions; you may modify and distribute derivative works provided you include license notices.
Quickstart
pip install pysr
import numpy as np
from pysr import PySRRegressor
X = np.random.randn(100, 5)
y = 2.5 * np.cos(X[:, 3]) + X[:, 0] ** 2
model = PySRRegressor(maxsize=20, niterations=40, binary_operators=["+", "*"], unary_operators=["cos", "sin"])
model.fit(X, y)
print(model.predict(X))
Requires Julia to be installed or will download it on first import; LD_LIBRARY_PATH conflicts with other Python packages loading libstdc++ may require manual configuration.
Verify before relying
- Whether the package handles datasets larger than typical low-dimensional symbolic regression benchmarks without significant performance degradation.
- Specific performance characteristics or memory requirements for typical use cases.
- Whether custom loss functions and operators are fully documented and stable across versions.
Package facts
| License | Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 7 — click, juliacall, numpy, pandas, scikit-learn, sympy, typing-extensions |
| Maintenance | actively maintained — 137 days since the last release |
| First released | |
| Downloads | 98,850/month — #13,056 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pysr-1.5.10-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
optlangOptlang formulates and solves linear,…
permissive · top 15,000 on PyPI
sympySymPy is a Python library for symbolic…
permissive · top 1,000 on PyPI
py-expression-evalParses and evaluates mathematical expressions…
permissive · top 15,000 on PyPI
math-verifyEvaluates mathematical expressions from LLM…
permissive · top 5,000 on PyPI
pyrootsImplements root-finding algorithms (bisect,…
permissive · top 15,000 on PyPI
latex2sympy2Parses LaTeX math expressions and converts them…
permissive · top 15,000 on PyPI
latex2sympy2-extendedParses LaTeX math expressions and converts them…
permissive · top 5,000 on PyPI
lineaxLineax solves linear systems and least-squares…
permissive · top 15,000 on PyPI
optimistixOptimistix provides nonlinear solvers for root…
permissive · top 15,000 on PyPI
pytensorPyTensor is a Python library for defining,…
permissive · top 5,000 on PyPI