This project implements a genetic algorithm in Go to perform symbolic regression. It evolves mathematical expressions to fit datasets by mimicking biological evolution processes.
- Expression Representation: Uses binary trees to represent and evolve mathematical functions.
- Speciation: Maintains population diversity by grouping similar individuals, preventing premature convergence.
- Elitism: Ensures the best-performing individuals are carried over to the next generation.
- Genetic Operators: Includes mutation and crossover to explore the solution space.
- Dataset Management: Logic to generate synthetic datasets or load existing ones.
- History Export: Evolution progress and statistics are exported as JSON for post-run analysis.
main.go: Entry point for dataset generation, evolution execution, and JSON export.analysis.ipynb: A Jupyter Notebook designed to read the JSON history files and visualize the results.
- Run Evolution:
or use the pre-compiled binary:
go run main.go datagen.go config.json ga_config.json
./symbolic_regression config.json ga_config.json
- Analyze Results:
Open
analysis.ipynbin a Jupyter environment to load the generated JSON data and inspect fitness curves and evolved expressions.
- Inspired by work of Kenneth Stanley phd thesis, paper