FastSymbolicGP: A Lightweight Python Library for Efficient Symbolic Regression and Classification
Nikola AnđelićSymbolic regression and symbolic classification generate explicit mathematical expressions that combine predictive modelling with direct model interpretability. However, symbolic learning based on genetic programming can be computationally expensive because large populations of candidate expressions must be repeatedly evaluated over multiple generations. This paper presents FastSymbolicGP, a lightweight Python library for symbolic regression, binary classification, and multiclass classification through a compact, scikit-learn-compatible interface. The library implements tree-based genetic programming, protected mathematical operators, tournament selection, subtree crossover, subtree, hoist, and point mutation, elitism, validation-aware model selection, adaptive parsimony, expression complexity analysis, and Numba-compiled postfix evaluation. FastSymbolicGP was evaluated through 940 successful benchmark runs covering real-world scientific regression, binary and multiclass classification, physical law recovery, dynamical system identification, parameter sensitivity, ablation, and scalability. Across four real-world scientific regression datasets, FastSymbolicGP achieved the highest mean test R2 on every dataset and obtained significantly better pooled paired results than gplearn and PySR under the evaluated configurations. These results are specific to the selected hyperparameters, primitive sets, stopping criteria, and computational budgets, and should not be interpreted as evidence of universal superiority. In binary classification, it achieved a mean balanced accuracy of 0.8507, compared with 0.7458 for gplearn, while validation-based threshold optimization and class weighting further improved performance under severe class imbalance. FastSymbolicGP also achieved competitive multiclass and dynamical system results while generally producing substantially simpler models than gplearn. In the scalability experiment with 50,000 samples, FastSymbolicGP was approximately 6.20 times faster than PySR and 1.63 times faster than gplearn, while obtaining predictive performance nearly identical to PySR. physical law experiments showed that nondimensionalization increased the dimensional validity rate of recovered FastSymbolicGP expressions from 24% to 96%, while reducing runtime and expression complexity. Analysis of the stored equation pools further showed that near-optimal model selection reduced symbolic complexity by an average of 28.6% when a simpler candidate was available, with negligible predictive degradation. These results indicate that FastSymbolicGP provides a practical balance of predictive performance, computational efficiency, task coverage, and symbolic interpretability for reproducible scientific and machine learning applications.