Skip to content

eshen7/symbolic-regression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Symbolic Regression Engine

The Symbolic Regression Engine uses genetic algorithms to discover mathematical equations to fit given data. It models equations as a tree-based structure like so:

image

The engine creates a population of individuals with "genes" that each encode an equation. The population undergoes a series of generations where they experience crossover, mutation, and fitness (natural selection) in order to simulate evolution. When two individuals cross over, they produce two offspring that have the same genes as their parents but with one node switched. Mutation either swaps an operator or generates a mini tree to replace a node. Fitness is evaluated as a combination of least-squares regression and a measure of complexity based on the number of nodes in the tree.

For example, when provided with the data (1, 1), (2, 4), (3, 9), (4, 16), (5, 25), the engine eventually outputs this:

Screenshot 2025-01-21 at 11 27 48 PM

Similarly, with (1, 1), (2, 8), (3, 27), (4, 64), (5, 125), we get this:

Screenshot 2025-01-21 at 11 29 05 PM

The Symbolic Regression Engine is designed in a way that it can operate on different representations for genes. For example, we can model a gene as a string of 1's and 0's. Through abstraction, the representation can be changed with virtually no code changes. The type of data can be changed as well, which can be used to incorporate more variables.

About

Symbolic regression engine using genetic algorithms

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages