Skip to main content

GP_ELITE

Find the formula behind your measurements: symbolic regression in pure Python.

PyPI Python Tests License: MIT Open In Colab

🇫🇷 Version française

GP_ELITE searches for a readable formula that links your variables to a target, instead of a black box. It is built for small experimental tables, up to about ten variables, where you want to understand the relationship: a physical law, a calibration, an engineering correlation.

GP_ELITE rediscovers Kepler's third law from 8 data points (R² = 1.000000)

Given only the distance and the orbital period of the eight planets, it finds Kepler's third law, T = a^1.5 (examples/kepler_demo.py):

import numpy as np
from gp_elite import symbolic_regression

a = np.array([0.387, 0.723, 1.000, 1.524, 5.203, 9.537, 19.191, 30.069])   # AU
T = np.array([0.241, 0.615, 1.000, 1.881, 11.862, 29.457, 84.011, 164.79])  # years

result = symbolic_regression(a.reshape(-1, 1), T, feature_names=["a"], generations=40, seed=0)
print(result.expression)     # 0.00279171 + 0.999396 * a * sqrt(a)

The formula is written in your variables and units: in astronomical units and years, Kepler's constant is 1, and that is what comes back.

Why GP_ELITE

  • Physical units as a hard constraint. Declare the units of your columns and the search builds only dimensionally sound formulas. It can also give the units and the value of a constant that is not in your data (physical units).
  • Pure Python and NumPy. pip install gp-elite: no Julia, no compiler, no GPU, Python 3.9 to 3.14.
  • Measured, not claimed. Every change meant to improve the search is decided by a comparison written before it runs, and published whatever the outcome (how GP_ELITE is measured).
  • Its limits are written down, each with the measurement behind it (what GP_ELITE does not do).

Install

pip install gp-elite

Or try it in your browser, with nothing to install: the quick start on Colab.

Quick start

On a CSV file, without code: run gp-elite, choose mode 6 (generic CSV) and keep the defaults. In Python, with X a table of measurements and y the target:

from gp_elite import symbolic_regression

if __name__ == "__main__":         # needed in scripts, not in notebooks
    result = symbolic_regression(X, y, feature_names=["a", "b"])
    print(result.expression)       # the formula, in your variables
    print(result.r2_validation)    # its score on rows held out (None below 30 rows)

With scikit-learn, GPEliteRegressor is an estimator like the others:

from gp_elite import GPEliteRegressor

est = GPEliteRegressor(units=["kg", "m/s"], target_units="J").fit(X, y)

Using GP_ELITE covers the options, how to read the result, and reproducibility.

What it finds, measured

In the release measurement of 1.4.0, five seeds and 30 s per fit, against 1.3.0 measured beside it (benchmarks/results_1.4/release/):

1.3.0 1.4.0
41 Feynman equations: exact law (of 205 fits) 171 171
the same with 1 % noise: structure of the law (of 205) 116 152
the same with 10 % noise: structure of the law (of 205) 87 95
the 41 with their physical units: exact law (of 205) 174 174
models returned under units that pass the audit of units 1,161 of 1,161 1,161 of 1,161

1.4 places more noise-tolerant seeds at the start of the search, forms its finders fit to the data: hence the gains under noise (what's new, CHANGELOG).

The structure of the law is retrieved when the returned model, its constants refitted on the noiseless data, reproduces the law. On 15 Feynman equations, head to head with gplearn on the same data, GP_ELITE returns 15 exact laws against 6. PySR and Operon are faster and more accurate on large or hard problems; GP_ELITE does not claim otherwise.

How the results are measured

The hypothesis and the criteria of each change meant to improve the search are committed before its first measurement. The change is adopted only if it meets them, and the results are published either way: for 1.4, four changes were measured and three were not adopted (its plan and campaigns). The correction of a fault is checked against the measured release instead, as for the one found in 1.4 before its release. Each release is also measured once on test sets frozen before any decision and never used to make one.

Documentation

Did it fail on your data? Please say so

GP_ELITE is tuned on published benchmarks, which are clean and well scaled. Real measurements are not, and that gap is where the engine most needs work. If it returns nonsense on your data, that is useful information, not user error: open an issue with the shape of your data and what you got back. You do not need to share the data itself, and you can write in English or French (CONTRIBUTING.md).

License and citation

MIT, see LICENSE: free to use, including commercially, with the copyright notice kept. If GP_ELITE is useful in academic work, see CITATION.cff.

Metadata

Release files for gp-elite 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gp-elite 1.4.0
File Size Uploaded Provenance Actions
gp_elite-1.4.0.tar.gz 272.4 kB Without provenance Details for gp_elite-1.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gp-elite 1.4.0
File Interpreter ABI Platform Actions
gp_elite-1.4.0-py3-none-any.whl Python 3 none any Details for gp_elite-1.4.0-py3-none-any.whl

Total release size: 504.2 kB

Release files / gp_elite-1.4.0.tar.gz

Download URL gp_elite-1.4.0.tar.gz
Size 272.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1ac9c146b711fd5910fd147234bb52e3f4e8603d28dced9fae0d87ff17d3c8a4
BLAKE2b-256 checksum
How to use checksums
951222f8a08b3592736c8f9f9bfda6acce4d255d7448f4d84c7fdd2adbf23f97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / gp_elite-1.4.0-py3-none-any.whl

Download URL gp_elite-1.4.0-py3-none-any.whl
Size 231.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2aae841bb04a374ba5ca08cf0204f332b14aec6ab3460ff4b4efe22044e5812e
BLAKE2b-256 checksum
How to use checksums
357f3bbbc8fd1759cc9eb01e38b0e74a4bda3b6eedafc38bee40567abae01128
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for gp-elite 1.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page