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). 1.5 changes no model: it organises the engine in modules, and at equal seed and equal work returns the models of 1.4.0, bit for bit, at the same speed, so these figures hold for it, within what a budget of 30 s per fit moves between two campaigns of the same version (up to three fits on these suites) (how the engine is organised).

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.5.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.5.0
File Size Uploaded Provenance Actions
gp_elite-1.5.0.tar.gz 288.5 kB Without provenance Details for gp_elite-1.5.0.tar.gz

Built distribution (wheel)

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

Total release size: 545.0 kB

Release files / gp_elite-1.5.0.tar.gz

Download URL gp_elite-1.5.0.tar.gz
Size 288.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b86591e409dc6ad9ab27aa8172d78ff1f54da62230635dee1e1d5a82b560501c
BLAKE2b-256 checksum
How to use checksums
cdc867695976e9fdf9e029ae9787aaaf3caca259ac882c42d6039cbbb416e168
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.5.0-py3-none-any.whl

Download URL gp_elite-1.5.0-py3-none-any.whl
Size 256.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
56ae15b33926f2d23d4589d5c2d4fbbac1cafd06daf4c60fc4975db9bca5959b
BLAKE2b-256 checksum
How to use checksums
a9a5f91ce2a6ebd6f0814ae56b3b3e446c79355e7c8effbe53ed43fc7580dbde
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.5.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