Symbolic regression

On this page 7

Symbolic regression is a form of regression analysis that searches over mathematical expressions to find both the structure and the parameters of a model that fits a data set. Unlike linear or polynomial regression, it does not fix the model form in advance: the algorithm decides whether the answer is a product, a ratio, an exponential or a trigonometric term. In evolutionary computation, it is the classic application of genetic programming, where candidate formulas evolve as expression trees.

The appeal is interpretability. A neural network may predict well but hides its reasoning in millions of weights, whereas symbolic regression returns a compact closed-form equation that a scientist can read, differentiate, check for units and compare with theory. The price is a hard combinatorial search that grows rapidly with formula size.

How symbolic regression searches for formulas

The search works on expression trees, where internal nodes are operators and leaves are input variables or constants. A genetic programming system starts with a random population of trees, evaluates each against the data with a fitness function such as mean squared error, and builds the next generation through selection, subtree crossover and mutation.

The table below lists the building blocks that every symbolic regression setup must define.

IngredientTypical choiceEffect on the search
Function set+, -, ×, ÷, sin, exp, logDefines which formula shapes are reachable
Terminal setInput variables and constantsDetermines which inputs can appear
Fitness measureMean squared error or R²Defines what counts as a good fit
Complexity penaltyNode count or tree depthControls formula length and bloat
Constant optimizationGradient descent or Levenberg–MarquardtTunes numeric coefficients inside a structure
Ingredients of a symbolic regression run

Most modern systems separate structure search from coefficient fitting. Evolution proposes the shape of a formula, and a local optimizer sets its constants, because random mutation alone finds precise real-valued coefficients very slowly.

Main approaches and algorithm families

Genetic programming is the historical core of the field, but several alternatives now compete with it. They differ in how they represent formulas and how they explore the space, which affects speed, reliability and the size of formulas they can recover.

ApproachRepresentationStrengthWeakness
Tree-based genetic programmingExpression treesFlexible, well studiedBloat and slow convergence
Cartesian genetic programmingDirected acyclic graphsReuses subexpressionsFixed grid size to tune
Grammatical evolutionInteger strings mapped by a grammarEnforces syntactic constraintsWeak locality of mutation
Sparse regressionLinear combination of library termsFast and deterministicLimited to terms in the library
Neural-guided searchSequences generated by a trained networkLearns priors over formulasNeeds large pretraining effort
Families of symbolic regression methods

Hybrid systems are common. Many combine evolutionary search with neural priors, or use a sparse library as a starting point for evolution. Benchmarks such as SRBench compare these methods on both accuracy and the exact recovery of known equations.

Accuracy, complexity and the Pareto front

Symbolic regression is inherently multi-objective: a longer formula almost always fits the training data better, yet it generalizes worse and is harder to read. Practitioners therefore report a Pareto front of formulas, each one the best fit for its level of complexity, often computed with a multi-objective evolutionary algorithm such as NSGA-II.

The choice from that front follows a simple pattern, shown below for a typical run.

Complexity (nodes)Training errorInterpretation
3-5HighToo simple, misses key effects
7-15Drops sharplyOften the best choice, the knee of the curve
20-40Slightly lowerUsually fitting noise
Over 50Near zero on training dataOverfitting and unreadable
Reading a Pareto front of candidate formulas

The knee of the Pareto front, where extra complexity stops buying meaningful accuracy, is the usual selection point. Validation on held-out data and a check that the formula is dimensionally consistent give further protection against spurious equations.

Where symbolic regression is applied

Symbolic regression is most valuable when an explicit formula is worth more than raw accuracy. Typical domains are physics, chemistry, engineering and finance, where an equation can be validated against theory, embedded in a simulator or certified by a regulator.

  • Scientific discovery: rediscovering conservation laws or empirical relations from experimental data.
  • Surrogate modeling: replacing an expensive simulation with a fast closed-form approximation.
  • Control and system identification: finding dynamic equations for controllers.
  • Feature engineering: generating nonlinear features for other machine learning models.

The method suits problems with few input variables, typically fewer than about ten, and data of reasonable quality. With hundreds of features or very noisy measurements, the search becomes slow and unstable, and a gradient boosting model or neural network usually predicts better, although it offers no compact equation in return.

Domain knowledge improves results considerably. Restricting the function set to physically plausible operators, supplying known invariants or enforcing unit consistency shrinks the search space and raises the chance of recovering a meaningful law rather than a curve fit. Simple preprocessing, such as scaling inputs and removing obvious outliers, also stabilizes the search.

Limitations and common pitfalls

The search space is enormous, and finding the exact optimal formula is believed to be NP-hard. Results therefore depend on random seeds, operator choice and run time, and two runs may return different but similarly accurate equations. The table lists frequent problems and remedies.

SymptomLikely causeRemedy
Formulas grow without accuracy gainBloat in genetic programmingAdd parsimony pressure or depth limits
Different formula every runFlat fitness landscape, noisy dataRun many seeds and compare fronts
Numerical errors during evaluationDivision by zero, log of negativesUse protected operators or interval checks
Good fit, poor extrapolationOverfitting to a narrow input rangeTest outside the training range
Typical problems in symbolic regression projects

A further pitfall is over-trusting a neat formula. A short equation that fits well is a hypothesis, not a discovered law, until it is tested on new data and checked against domain knowledge.

Understanding it simply

Symbolic regression is like a detective that guesses the formula behind a table of numbers. It tries many equations, keeps the ones that match best and mixes their parts to make new guesses.

Ordinary regression asks how steep a straight line should be. Symbolic regression asks a bigger question. It asks what kind of equation describes the data at all. The result is a formula a person can read and check, not a black box.

Applied in practice

A heat-exchanger engineering team has a computational fluid dynamics model that needs about 40 minutes per run. They need thousands of evaluations for design optimization, so they run 600 simulations across flow rate, fin spacing and inlet temperature and feed the results to a genetic programming tool.

After several hundred generations across 20 random seeds, the Pareto front shows a clear knee at a formula with 11 nodes: a power law in flow rate multiplied by a ratio involving fin spacing. It predicts heat transfer within about 3 percent on held-out simulations and matches the form of known empirical correlations.

The team embeds the formula in its optimizer, which now evaluates a design in microseconds. Because the equation is explicit, the engineers can also verify its units and document its validity range for the design review.