genepro
In brief
genepro is a Python library providing a baseline implementation of genetic programming, an evolutionary algorithm specialized to evolve programs.
This library includes a classifier and regressor that are compatible with scitik-learn (see examples of usage below).
Evolving programs are represented as trees. The leaf nodes (also called terminals) of such trees represent some form of input, e.g., a feature for classification or regression, or a type of environmental observation for reinforcement learning. The internal nodes represent possible atomic instructions, e.g., summation, subtraction, multiplication, division, but also if-then-else or similar programming constructs.
Genetic programming operates on a population of trees, typically initialized at random. Every iteration (called generation), promising trees undergo random modifications (e.g., forms of crossover, mutation, and tuning) that result in a population of offspring trees. This new population is then used for the next generation.
Installation
For classification or regression, genepro relies only on a few libraries (numpy, joblib, and scikit-learn).
However, additional libraries (e.g., gym) are required to run the reinforcement learning example.
Thus, you can choose to perform a minimal or full installation.
Minimal installation
To perform a minimal installation, run:
pip install genepro
Full installation
For a full installation, clone this repo locally, and make use of the file requirements.txt, as follows:
git clone https://github.com/marcovirgolin/genepro
cd genepro
pip install -r requirements.txt .
Wish to use conda?
A conda virtual enviroment can easily be set up with:
git clone https://github.com/marcovirgolin/genepro
cd genepro
conda env create
conda activate genepro
pip install .
Examples of usage
Classification and regression
The notebook classification and regression.ipynb shows how to use genepro for classification and regression, via scikit-learn estimators.
These estimators are intended for data sets with a small number of (relevant) features, as the evolved program can be written as a compact (and potentially interpretable) symbolic expression.
...
gen: 39, best of gen fitness: -2952.999, best of gen size: 46
gen: 40, best of gen fitness: -2950.453, best of gen size: 44
The mean squared error on the test set is 2964.646 (respective R^2 score is 0.512)
Obtained by the (simplified) model: 146.527 + -5.797*(-x_2**2 - 4*x_2 - 3*x_3 + 2*x_4 - x_5 - x_6*(x_4 - x_5) + x_6 - 5*x_8)
Example of output of a symbolic regression model discovered for the Diabetes data set.
Reinforcement learning
The notebook gym.ipynb shows how genepro can be used to evolve a controller for the CartPole-v1 environment of the OpenAI gym library.
(x2 + x3) * (x2*x3 + x3 + x4 + 1) * log(abs(x2))^2 * log(abs(x3))^2 < 0.5? 'left' else 'right'
Citation
If you use this software, please cite it with:
@software{Virgolin_genepro_2022,
author = {Virgolin, Marco},
month = {9},
title = {{genepro}},
url = {https://github.com/marcovirgolin/genepro},
version = {0.1.3},
year = {2024}
}
Metadata
Release files for genepro 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| genepro-0.1.3.tar.gz | 28.0 kB | Without provenance | Details for genepro-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| genepro-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for genepro-0.1.3-py3-none-any.whl |
Total release size: 56.4 kB
Release files / genepro-0.1.3.tar.gz
| Download URL | genepro-0.1.3.tar.gz |
|---|---|
| Size | 28.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3698188e5b09b17c8543093e58c4d5c623c1f1ec246f70d6e5226248a8e7253e
|
|
BLAKE2b-256 checksum How to use checksums |
34c8fdb3a217dbb1b7f111b21052edf2bd0e5c0b13f60b13b047b686d9bd9548
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.5
|
Release files / genepro-0.1.3-py3-none-any.whl
| Download URL | genepro-0.1.3-py3-none-any.whl |
|---|---|
| Size | 28.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9b420c4b3b0e2806a8ea02970b611228ae37af4a884f73288147b6aad8775ca9
|
|
BLAKE2b-256 checksum How to use checksums |
950843bb511bcbbb2bcbc581743b011a4612116e29c5b7088e6c170c2bddf433
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.5
|
Security for genepro 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.