Genetic programming that speaks scikit-learn natively
It brings genetic programming’s formula-evolving trick into scikit-learn’s familiar fit/predict world.

What it does
gplearn performs symbolic regression: it evolves populations of random mathematical formulas to find an expression that best fits your data. It wraps this genetic programming machinery in scikit-learn-compatible estimators—SymbolicRegressor, SymbolicClassifier, and SymbolicTransformer—so you can drop them into pipelines and grid searches. The project deliberately narrows the broad field of genetic programming to this single, practical task.
The interesting bit
The value is in the constraint. Rather than building a sprawling GP framework, gplearn treats evolved formulas as just another scikit-learn estimator, complete with fit and predict. That makes automated feature engineering via genetic programming feel like swapping out a linear model.
Key highlights
- Implements
SymbolicRegressor,SymbolicClassifier, andSymbolicTransformerfor regression, binary classification, and feature engineering. - Works natively with scikit-learn
Pipelineand grid search modules. - Evolves formulas through successive generations of selection and genetic operations.
- Exposes many tunable parameters, though the documentation claims to clarify the relevant ones.
Caveats
- The README notes there are “a lot of parameters to tweak,” which suggests a learning curve.
- Classification is explicitly limited to binary problems.
- Requires a fairly recent scikit-learn version, which may complicate legacy environments.
Verdict
Worth a look if you want interpretable, evolved equations inside a standard scikit-learn workflow. Skip it if you need multiclass classification or a general-purpose genetic programming toolkit.
Frequently asked
- What is trevorstephens/gplearn?
- It brings genetic programming’s formula-evolving trick into scikit-learn’s familiar fit/predict world.
- Is gplearn open source?
- Yes — trevorstephens/gplearn is open source, released under the BSD-3-Clause license.
- What language is gplearn written in?
- trevorstephens/gplearn is primarily written in Python.
- How popular is gplearn?
- trevorstephens/gplearn has 1.9k stars on GitHub.
- Where can I find gplearn?
- trevorstephens/gplearn is on GitHub at https://github.com/trevorstephens/gplearn.