eqdisco: discovering equations from data#

eqdisco

eqdisco searches the space of mathematical expressions for equations that explain data, and then helps to understand, check and deploy what it found. It is the Python successor of the GP-OLS MATLAB toolbox of Madár, Abonyi and Szeifert (Ind. Eng. Chem. Res., 2005), in which genetic programming proposes the structure of a linear-in-parameters model and orthogonal least squares prunes the terms that do not contribute. Around this method the package collects the families of symbolic regression that have proved themselves in the literature, adds several new ones, and provides tools for domain knowledge, model analysis and MLOps. Every estimator follows the scikit-learn API.

Genetic programming

Tree GP with linear scaling, Levenberg–Marquardt constants, lexicase, NSGA-II and age–fitness Pareto selection, islands, model selection.

Genetic programming for symbolic regression
GP-OLS and multi-gene GP

Linear-in-parameters models, error reduction ratios, OLS pruning, ERR-guided variation and the cooperative OLS–GP library.

Linear-in-parameters models: OLS, multi-gene GP and GP-OLS
Sparse and exhaustive search

STLSQ, Lasso, FROLS and best subset on term libraries; FFX; enumeration of all small expressions with MDL selection.

Deterministic search: sparse regression, FFX and exhaustive enumeration
Probabilistic and LLM-guided search

The Bayesian machine scientist, risk-seeking grammar cross-entropy search, and a safe protocol for expressions proposed by language models.

Probabilistic search: Bayesian sampling, grammars and language models
Dynamic systems

NARX identification with GP-OLS, order selection, free-run simulation, SINDy and symbolic ODEs.

Dynamic systems: NARX models and differential equations
Beyond regression

Critical-equation classifiers and goal-oriented symbolic projections for visualization and soft sensors.

Beyond regression: classification and symbolic features
Domain knowledge

Units and dimensional consistency, Buckingham Π, shape constraints, separability and symmetry tests.

Prior knowledge: units, shape constraints and symmetries
Model analysis

Simplification, validation, confidence and prediction intervals, Sobol indices, building blocks, model families, ensembles.

Analysis of models: simplification, validation, uncertainty, structure
MLOps

Code generation, PMML, model registry and cards, drift monitoring, benchmarks, one-page reports.

From model to deployment: export, registry, monitoring, benchmarks

Quick start#

import numpy as np
import eqdisco as eq

planets = eq.datasets.load_kepler()                    # semi-major axis a, period T
sr = eq.SymbolicRegressor(population_size=300, generations=25, feature_names=["a"],
                          functions=("add", "sub", "mul", "div", "sqrt"), random_state=0)
sr.fit(planets[["a"]].to_numpy(), planets["T"].to_numpy())
print(sr.equation_)                                    # 0.003055 + 0.9994 * sqrt(a) * a
eq.viz.plot_pareto(sr)                                 # accuracy against complexity
print(eq.export.to_c(sr.equation_))                    # deployable code