This repository provides the implementation of QDSR, a state-of-the-art symbolic regression engine that integrates:
- Quality-Diversity (QD) search for improved exploration,
- Dimensional analysis (DA) for physics-inspired constraints (optional).
QDSR achieves high exact recovery rates on benchmark datasets, surpassing existing methods by a large margin.
🔗 Reference: If you use QDSR in your work, please cite our paper: arXiv:2503.19043.
- Clone this repository:
git clone https://github.com/jpbruneton/QDSR.git cd QDSR - Install requirements:
pip install -r requirements.txt
🔧 Usage
To test QDSR on the Feynman-AI dataset from SR-Bench:
- Download the dataset (with units) from the Feynman-AI website : https://space.mit.edu/home/tegmark/aifeynman.html
- Unzip it into the following directory: Targets/Feynman_with_units/raw_data/ There should be 117 csv files (do not forget to unzip bonus equation as well, named test_1... to test_20.csv)
- Check config/config.py to define metaparameters such as max length, time bufget, verbosity level, etc
- Run python Launch_Feynman.py
To apply QDSR to your own dataset:
- Modify Launch_from_file.py
- Set the name and path of your dataset
- Set the number of variables in your dataset.
- Define their physical dimensions (if applicable; if not, set them all to zero)
- Specify the dimension of the target variable (if using DA).
- Run the script: python Launch_from_file.py
To test whether QDSR can rediscover a known equation:
- Modify Launch_custom_run.py
- Set equation you want to use, name the dataset and dimension of variables
- Make sure your equation is dimensionnaly consistent
- Run the script: python Launch_custom_run.py
In config/config.py, you can
- Change the number of allowed nested functions (set to 2, ie, sin(sin(tan(...))) is not allowed.
- Change the metric from R2 to NMRSE
- Change the termination_loss
- Enforce or not bounds on the free scalars parameters (default False)
- Modify at will the list of unaries used
- Directly set the number of CPU by hand by changing def default_n_cores to return n, where n is the desired number
- Allow or not dimensional analysis
- Allow or not leaf vocabulary extension as explained in the paper
- Allow or not sqrt and power nodes
- Add noise to the data
- Change the run parameter (number of iterations, etc)
- Change the maximal length of equations
- Change the QD grid size
- Other misc options, like verbosity
QDSR leverages Quality-Diversity (QD) to improve exploration, allowing for more exact recoveries compared to standard evolutionary methods.
Dimensional Analysis (DA): When enabled through 'apply_dimensional_analysis' flag in config.py, QDSR ensures all expressions are dimensionally consistent, significantly boosting performance on physics-based datasets.
Flexible vocabulary: The engine supports a wide range of functions, including trigonometric, hyperbolic, and inverse functions, for better expression discovery (you can modify the list in config.py). The engine will also automatically create dimensionless variables and scalar products as explained in the paper via the other flags : 'add_adim_variables', 'add_inverse', 'add_products', and 'add_norms'
📄 License This project is released under the MIT License.
For questions or contributions, feel free to open an issue or submit a pull request.