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.6.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.6-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.6-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.6-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.6-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.6-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.6-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.6-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.6-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.6-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.6-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.6.tar.gz.

File metadata

  • Download URL: bingo_nasa-0.5.6.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.6.tar.gz
Algorithm Hash digest
SHA256 6c7eb4e344b9bc87f8104bc1f3f6702daa6b23b0fcba576e026888f0c134bca6
MD5 f15c4385c2a180075fbdb008a51f4d28
BLAKE2b-256 6620928900dd491fd3816102dfb0b61b8597e85c775549f2de0f81cd19d99c3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.6.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.6-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for bingo_nasa-0.5.6-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 df9e72cdd12af1005b058932660daf166880c1e3f2ea30249d42ab7ad722bd26
MD5 5d79a008ccec0750fa5527ce187bb2de
BLAKE2b-256 a5ccc70fd1b610bd3c4a314997b17f45c6a55d76ea5f577b23769790156205e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.6-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.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bingo_nasa-0.5.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8e527e95a4e7e2ee2f73a737b9826d2d43dcac4896997ec430879ae7a35e7093
MD5 75a2b84b897132abec328b5d57a273a6
BLAKE2b-256 8d2fad477de954503adec2d9e8a3b41f72e2cfb13dd2d6c5d51b8b17778bbfca

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.6-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.6-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for bingo_nasa-0.5.6-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8afd603aa5f603a8c1425d94ec85cf489b9bb99b1d5114d0d6ca19318464ee04
MD5 dfab64ce4bf694649cef7e431ca36a18
BLAKE2b-256 371c5ae80e44ec5f534c76445dc3fb17639609c18944f25770d83ad2bfefeaac

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.6-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.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bingo_nasa-0.5.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eb77565ae656422ccf904fed7f20f99494dbedbd4b7f194840b97002bd7d39a9
MD5 8dfb2131706ce745cda05ce9b18f335d
BLAKE2b-256 8f60c7185dcb03aea06a8fba7e8bf774c0e87cd4347eee7cdd1dc9eaede7656c

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.6-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.6-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for bingo_nasa-0.5.6-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c267061cd58c4c5bb1077d21fa3abbd6e605ba9a3e5649efadb4c313ab11361e
MD5 7abf8246a203499a4c9de57499390f7e
BLAKE2b-256 258f892c07945368cd9d9fc17579077a15985d0c8fc08309c7077f8fd64fdd01

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.6-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.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bingo_nasa-0.5.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fdd0bb2b96359fe85d17d163d95038879f3d5052118705cc2ccc07432a0f121b
MD5 3535568038a0954ad0313b504a7a5327
BLAKE2b-256 8c376ae2b09e592d99dea165746d54d3844c1240055125fb276ba161b4935bbb

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.6-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.6-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for bingo_nasa-0.5.6-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f60e606b3b51820ca96383149175896fcd96efa743f6de9cf3b8b12c60de8a2a
MD5 b876106f45493b161b71d8b669a018d8
BLAKE2b-256 b54d6d69a3ba2a857fb15180d78861db2273b690020dc044e9db5dbb024b9542

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.6-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.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bingo_nasa-0.5.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 28740f91731aded7766e79ddf7f3d843b58107da48bf5e1c8e99176fdd2ee51a
MD5 99ff62b4c841831333d9f375a3d9a829
BLAKE2b-256 8a6170d50a5257be8304bbeac185e21dd7cb1493e963ec6e2c919a25d723eecd

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.6-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.6-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for bingo_nasa-0.5.6-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 95d54aaecefab410497627e3d04e484f891d06f1f4b3b797b6b02187b0ad0512
MD5 dd8e9a59a813b6638750a1c182cfa74b
BLAKE2b-256 88445952c803960bd23e3652808fe5e83bbce6a18dc67a4e8570e55c1e450d0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.6-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.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bingo_nasa-0.5.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bc7ca6b12e92a7fe9e0bde40d6109b976b1e46dba61e8a98a7102765c5c0739a
MD5 fd5aefb66579874e679ac3b111ef5e77
BLAKE2b-256 58f820b2ba70f987e14bbf37933e5c30aa18c88f824d4a7372c7759d888a23c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for bingo_nasa-0.5.6-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