Skip to main content

A package for genetic optimization and symbolic regression.

Project description

Bingo Logo

master: Build Status Coverage Status

develop: Build Status Coverage Status

Description

Bingo is an open source package for performing symbolic regression, though it can be used as a general purpose evolutionary optimization package.

Key Features

  • Integrated local optimization strategies
  • Parallel island evolution strategy implemented with mpi4py
  • Coevolution of fitness predictors

Quick Start

Documentation

Full Documentation Here

Installation

pip install bingo-nasa

Usage Example

A no-fuss way of using Bingo is by using the scikit-learn wrapper: SymbolicRegressor. Let's setup a test case to show how it works.

Setting Up the Regressor

There are many options that can be set in SymbolicRegressor. Here we set some basic ones including population_size (the number of equations in a population), stack_size (the max number of nodes per equation), and use_simplification (whether to use simplification to speed up equation evaluation and for easier reading). You can see all of SymbolicRegressor's options here.

from bingo.symbolic_regression.symbolic_regressor import SymbolicRegressor
regressor = SymbolicRegressor(population_size=100, stack_size=16,
                              use_simplification=True)
/home/gbomarit/Projects/Genetic_Programming/bingo/bingo/symbolic_regression/__init__.py:31: UserWarning: Could not load C++ modules No module named 'bingocpp.build.bingocpp'
  warnings.warn(f"Could not load C++ modules {import_err}")

Training Data

Here we're just creating some dummy training data from the equation $5.0 X_0^2 + 3.5 X_0$. More on training data can be found in the data formatting guide.

import numpy as np
X_0 = np.linspace(-10, 10, num=30).reshape((-1, 1))
X = np.array(X_0)
y = 5.0 * X_0 ** 2 + 3.5 * X_0
import matplotlib.pyplot as plt
plt.scatter(X, y)
plt.xlabel("X_0")
plt.ylabel("y")
plt.title("Training Data")
plt.show()

png

Fitting the Regressor

Fitting is as simple as calling the .fit() method.

regressor.fit(X, y)
using 1 processes
 Generating a diverse population took 274 iterations.
archipelago: <class 'bingo.evolutionary_optimizers.island.Island'>
done with opt, best_ind: X_0 + (5.0)((0.49999999999999967)(X_0) + (X_0)(X_0)), fitness: 5.4391466376923e-28
reran CLO, best_ind: X_0 + (5.0)((0.4999999999999999)(X_0) + (X_0)(X_0)), fitness: 5.352980018399097e-28

Getting the Best Individual

best_individual = regressor.get_best_individual()
print("best individual is:", best_individual)
best individual is: X_0 + (5.0)((0.4999999999999999)(X_0) + (X_0)(X_0))

Predicting Data with the Best Individual

You can use the regressor's .predict(X) or the best_individual's .evaluate_equation_at(X) to get its predictions for X.

pred_y = regressor.predict(X)
pred_y = best_individual.evaluate_equation_at(X)

plt.scatter(X, y)
plt.plot(X, pred_y, 'r')
plt.xlabel("X_0")
plt.ylabel("y")
plt.legend(["Actual", "Predicted"])
plt.show()

png

Source

Installation from Source

For those looking to develop their own features in Bingo.

First clone the repo and move into the directory:

git clone --recurse-submodules https://github.com/nasa/bingo.git
cd bingo

Then make sure you have the requirements necessary to use Bingo:

conda env create -f conda_environment.yml

or

pip install -r requirements.txt

(Optional) Then build the c++ performance library BingoCpp:

./.build_bingocpp.sh

Now you should be good to go! You can run Bingo's test suite to make sure that the installation process worked properly:

pytest tests

Add Bingo to your Python path to begin using it from other directories.

export PYTHONPATH="$PYTHONPATH:/path/to/bingo/"

and test it with:

python -c 'import bingo; import bingocpp'

Contributing

  1. Fork it (https://github.com/nasa/bingo/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Citing Bingo

Please consider citing the following reference when using bingo in your works.

MLA:

Randall, David L., et al. "Bingo: a customizable framework for symbolic regression with genetic programming." Proceedings of the Genetic and Evolutionary Computation Conference Companion. 2022.

Bibtex:

@inproceedings{randall2022bingo,
  title={Bingo: a customizable framework for symbolic regression with genetic programming},
  author={Randall, David L and Townsend, Tyler S and Hochhalter, Jacob D and Bomarito, Geoffrey F},
  booktitle={Proceedings of the Genetic and Evolutionary Computation Conference Companion},
  pages={2282--2288},
  year={2022}
}

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Geoffrey Bomarito
  • Tyler Townsend
  • Jacob Hochhalter
  • David Randall
  • Ethan Adams
  • Kathryn Esham
  • Diana Vera

License

Copyright 2018 United States Government as represented by the Administrator of the National Aeronautics and Space Administration. No copyright is claimed in the United States under Title 17, U.S. Code. All Other Rights Reserved.

The Bingo Mini-app framework is licensed under the Apache License, Version 2.0 (the "License"); you may not use this application except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 .

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bingo_nasa-0.5.7.tar.gz (2.5 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

bingo_nasa-0.5.7-cp313-cp313-musllinux_1_2_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

bingo_nasa-0.5.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (420.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

bingo_nasa-0.5.7-cp312-cp312-musllinux_1_2_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

bingo_nasa-0.5.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (420.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

bingo_nasa-0.5.7-cp311-cp311-musllinux_1_2_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

bingo_nasa-0.5.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (422.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

bingo_nasa-0.5.7-cp310-cp310-musllinux_1_2_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

bingo_nasa-0.5.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (421.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

bingo_nasa-0.5.7-cp39-cp39-musllinux_1_2_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ x86-64

bingo_nasa-0.5.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (421.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

File details

Details for the file bingo_nasa-0.5.7.tar.gz.

File metadata

  • Download URL: bingo_nasa-0.5.7.tar.gz
  • Upload date:
  • Size: 2.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bingo_nasa-0.5.7.tar.gz
Algorithm Hash digest
SHA256 8c70f3345650bc351717bc978cc84c3b81870cd1c49f2ebc35374babd6fad5f1
MD5 87cf699bfd715a92ad554010cadac2f8
BLAKE2b-256 b845794d0e71c1b5d694fcf8772f2de6cf1227206fc8a16bf21b38c1d44a72d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.7.tar.gz:

Publisher: pypi.yml on nasa/bingo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bingo_nasa-0.5.7-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for bingo_nasa-0.5.7-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 236bbc60064ac4216e1823886d9b1ef4fd2493ae1764a74a3fd2a342aebda6c9
MD5 242e9d422e89ef652df2d93432262df1
BLAKE2b-256 64c5d3961c158965a432d41f34e2ffe92de4891278ffb07d6914773c96a0a0a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.7-cp313-cp313-musllinux_1_2_x86_64.whl:

Publisher: pypi.yml on nasa/bingo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bingo_nasa-0.5.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bingo_nasa-0.5.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bd475111e922e5fbca07d141b64e5cf1dd9a3d32662f42b10101c42ee4d44085
MD5 3c28137c8a49293b30db955d38b63c99
BLAKE2b-256 c30c180c9fcf1edadbabbb6a9444e0d9400856a4633144c18f3971096e579d13

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: pypi.yml on nasa/bingo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bingo_nasa-0.5.7-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for bingo_nasa-0.5.7-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9c3d54d28a91908599f871aab04418c9a44e4feb71460c1aed9a0bc6d7d8d6d1
MD5 13580bfc0ac2e46c14f01a339f86ff24
BLAKE2b-256 a45385444208f5651d379fa0bf99fbd227bd4f4d4bb6d00998e9bbbfc4fa9521

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.7-cp312-cp312-musllinux_1_2_x86_64.whl:

Publisher: pypi.yml on nasa/bingo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bingo_nasa-0.5.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bingo_nasa-0.5.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a163b528cf8d4c6dd1a454c4e90d7446fbedd19f9ea4862070725ea7773215a3
MD5 69185a030068168d4d25bff6d25b0161
BLAKE2b-256 44479feb58eadc23198e82152c7d6692cf3d9b1333c74347ae6111faed7e74c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: pypi.yml on nasa/bingo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bingo_nasa-0.5.7-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for bingo_nasa-0.5.7-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 48e3c84c7685936da0fe277f3dff8f9acab4baad9fca0b001eea487debc4d936
MD5 c1889024b1e4118926187a5a3f5ce43d
BLAKE2b-256 d1c06c0829f3bcc3babaed1d93c755a9e3321aa4c588eb99eea2e4236e1b89d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.7-cp311-cp311-musllinux_1_2_x86_64.whl:

Publisher: pypi.yml on nasa/bingo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bingo_nasa-0.5.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bingo_nasa-0.5.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5693c9fdbafb46b4c09c1f3998c2af2ff2259d60f1e94bbcd5661d98a9759078
MD5 0b0208ac99750d56411054be90cfcead
BLAKE2b-256 999d5bf364c1455c89b9d7e065bea40630920d51e23910beb2296b861677c070

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: pypi.yml on nasa/bingo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bingo_nasa-0.5.7-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for bingo_nasa-0.5.7-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 37ab02d9c5c846bb524f960726ccbdf9e1eb7e7d2d3235afbbcf17e673bac8bf
MD5 c9622800c63d94a5f810cf32737fd438
BLAKE2b-256 4e83d75010e1b36f699cb30a15ffcbc2691ed9869b49b25b6d4c57a3c8ac2b6c

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.7-cp310-cp310-musllinux_1_2_x86_64.whl:

Publisher: pypi.yml on nasa/bingo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bingo_nasa-0.5.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bingo_nasa-0.5.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f1d486226c6ca5dc61edba648ba3d74e0ec6f1e487b8a3648a1f65150d2fedaf
MD5 1432f2a53bcf3c76674e6efd8caec4a3
BLAKE2b-256 08471e9fc3875e41b941e59b1dc7a01ac969cd9def2e20dee05c6faaca66ac0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: pypi.yml on nasa/bingo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bingo_nasa-0.5.7-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for bingo_nasa-0.5.7-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 245615b377cc0d77d894d246dbc0cf7b6b4c5322e687e0c8f8fc19a5505112d2
MD5 6715057120f2d19a492a001d98815b29
BLAKE2b-256 687c3dd574d4a4a95bd98ff3db64b865a02ce966ffb07b77d1e41df886145c20

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.7-cp39-cp39-musllinux_1_2_x86_64.whl:

Publisher: pypi.yml on nasa/bingo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bingo_nasa-0.5.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bingo_nasa-0.5.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7a539d1355c7fb8a9cdf318188f404f514c5760a00fc8d6282672ce7dbd56379
MD5 81f17d3d7895c4bcad524e9362f3d119
BLAKE2b-256 701869272eed6b6b2aa2f36c60a7a0791b6976169d84bc12cbefb937b47c11cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: pypi.yml on nasa/bingo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page