A strongly-typed genetic programming framework for Python

Overview

monkeys

PyPI version

"If an army of monkeys were strumming on typewriters they might write all the books in the British Museum."

monkeys is a framework designed to make genetic programming in Python accessible, quick, flexible, and fun.

Get started here.

What is genetic programming?

Genetic programming algorithms are a class of evolutionary algorithms in which solutions to a problem are represented as executable tree structures - programs. In order to use genetic programming in order to solve a problem, two things must be specified:

  1. What form(s) a potential solution can take.

  2. A method of scoring solutions based on their meritoriousness.

Given these, a genetic programming system can perform intelligent exploration and search through the space of potential solutions, narrowing in on those programs that best solve the problem as specified. Genetic programming has achieved human-competitive results in a wide swath of domains, including:

monkeys to the rescue!

"Ford, there's an infinite number of monkeys outside who want to talk to us about this script for Hamlet they've worked out."

monkeys makes getting started with genetic programming painless and fun. Install monkeys by running:

pip install monkeys

monkeys uses a variant of genetic programming called "strongly-typed genetic programming" in order to allow you to quickly and easily specify how your programs should be structured.

monkeys supports Python 2.7 and 3.x.

Examples

Tutorials:

Sample usages:

Contacts

You might also like...
Code for the paper
Code for the paper "JANUS: Parallel Tempered Genetic Algorithm Guided by Deep Neural Networks for Inverse Molecular Design"

JANUS: Parallel Tempered Genetic Algorithm Guided by Deep Neural Networks for Inverse Molecular Design This repository contains code for the paper: JA

Grow Function: Generate 3D Stacked Bifurcating Double Deep Cellular Automata based organisms which differentiate using a Genetic Algorithm...
Grow Function: Generate 3D Stacked Bifurcating Double Deep Cellular Automata based organisms which differentiate using a Genetic Algorithm...

Grow Function: A 3D Stacked Bifurcating Double Deep Cellular Automata which differentiates using a Genetic Algorithm... TLDR;High Def Trees that you can mint as NFTs on Solana

A simple and lightweight genetic algorithm for optimization of any machine learning model

geneticml This package contains a simple and lightweight genetic algorithm for optimization of any machine learning model. Installation Use pip to ins

Simulate genealogical trees and genomic sequence data using population genetic models

msprime msprime is a population genetics simulator based on tskit. Msprime can simulate random ancestral histories for a sample of individuals (consis

Where-Got-Time - An NUS timetable generator which uses a genetic algorithm to optimise timetables to suit the needs of NUS students ⚡ Fast • 🪶 Lightweight • 0️⃣ Dependency • 🔌 Pluggable • 😈 TLS interception • 🔒 DNS-over-HTTPS • 🔥 Poor Man's VPN • ⏪ Reverse & ⏩ Forward • 👮🏿 aka
aka "Bayesian Methods for Hackers": An introduction to Bayesian methods + probabilistic programming with a computation/understanding-first, mathematics-second point of view. All in pure Python ;)

Bayesian Methods for Hackers Using Python and PyMC The Bayesian method is the natural approach to inference, yet it is hidden from readers behind chap

Deep universal probabilistic programming with Python and PyTorch
Deep universal probabilistic programming with Python and PyTorch

Getting Started | Documentation | Community | Contributing Pyro is a flexible, scalable deep probabilistic programming library built on PyTorch. Notab

Comments
  • assertions_as_score must not set max score for complex functions

    assertions_as_score must not set max score for complex functions

    assertions_as_score cannot determine maximum score for functions in which Assert nodes are descendants of control structures (If, While, For). In these cases, simply leave max score unset.

    opened by hchasestevens 0
  • How to use multiple types?

    How to use multiple types?

    Hi,

    I tried the following code, attempting to use two types : @params(bool,float,float) @rtype(float) def IfCond(c,a,b): if c==True : return a return b

    recevied the following error:

    File "twoTypes.py", line 64, in IfCond if c==True :

    TypeError: 'bool' object is not callable

    I wanted my function to receive a boolean value (produced by a function with a boolean rtype, for example) and return either a or b, depending upon that value

    Could anyone please correct my code, or provide a working example with a boolean-returning function, used by a float-returning function?

    Thanks in advance! Ami

    opened by AmikoAce 0
  • Another Error at

    Another Error at "Getting started" notebook

    When running

    best_equation = optimize(score)

    I'm getting the error:

    TypeError: bad operand type for unary -: 'NoneType'

    I can post the whole traceback if it helps.

    opened by RabbitJackTrade 0
  • AST example: unable to reproduce evolved my_abs function

    AST example: unable to reproduce evolved my_abs function

    Running Monkeys in abstract syntax trees in Jupyter (on Python 2.7), I was unable to reproduce the result in the original notebook.

    from monkeys.tools.display import type_graph
    type_graph()
    

    The code above generated the exact same type graph as shown in the original notebook. So far so good. However, when calling optimize

    best_abs = optimize(score, iterations=25)
    

    it never managed to output a useful abs function. Most of the time the output was either

    def my_abs(x):
        return int(x)
    

    or

    def my_abs(x):
        return int(-x)
    

    After dumping all the generated intermediary ASTs, I have noticed that the conditional if_else never once appeared in any of the generated trees. What might be the reason for this?

    opened by klaufir216 0
Owner
H. Chase Stevens
Metaprogramming, natural language processing, and global optimization technique enthusiast.
H. Chase Stevens
A Python Automated Machine Learning tool that optimizes machine learning pipelines using genetic programming.

Master status: Development status: Package information: TPOT stands for Tree-based Pipeline Optimization Tool. Consider TPOT your Data Science Assista

Epistasis Lab at UPenn 8.9k Dec 30, 2022
Genetic Programming in Python, with a scikit-learn inspired API

Welcome to gplearn! gplearn implements Genetic Programming in Python, with a scikit-learn inspired and compatible API. While Genetic Programming (GP)

Trevor Stephens 1.3k Jan 3, 2023
A Genetic Programming platform for Python with TensorFlow for wicked-fast CPU and GPU support.

Karoo GP Karoo GP is an evolutionary algorithm, a genetic programming application suite written in Python which supports both symbolic regression and

Kai Staats 149 Jan 9, 2023
Use deep learning, genetic programming and other methods to predict stock and market movements

StockPredictions Use classic tricks, neural networks, deep learning, genetic programming and other methods to predict stock and market movements. Both

Linda MacPhee-Cobb 386 Jan 3, 2023
GrailQA: Strongly Generalizable Question Answering

GrailQA is a new large-scale, high-quality KBQA dataset with 64,331 questions annotated with both answers and corresponding logical forms in different syntax (i.e., SPARQL, S-expression, etc.). It can be used to test three levels of generalization in KBQA: i.i.d., compositional, and zero-shot.

OSU DKI Lab 76 Dec 21, 2022
Named Entity Recognition with Small Strongly Labeled and Large Weakly Labeled Data

Named Entity Recognition with Small Strongly Labeled and Large Weakly Labeled Data arXiv This is the code base for weakly supervised NER. We provide a

Amazon 92 Jan 4, 2023
This is the repo for the paper `SumGNN: Multi-typed Drug Interaction Prediction via Efficient Knowledge Graph Summarization'. (published in Bioinformatics'21)

SumGNN: Multi-typed Drug Interaction Prediction via Efficient Knowledge Graph Summarization This is the code for our paper ``SumGNN: Multi-typed Drug

Yue Yu 58 Dec 21, 2022
PyGAD, a Python 3 library for building the genetic algorithm and training machine learning algorithms (Keras & PyTorch).

PyGAD: Genetic Algorithm in Python PyGAD is an open-source easy-to-use Python 3 library for building the genetic algorithm and optimizing machine lear

Ahmed Gad 1.1k Dec 26, 2022
Genetic Algorithm, Particle Swarm Optimization, Simulated Annealing, Ant Colony Optimization Algorithm,Immune Algorithm, Artificial Fish Swarm Algorithm, Differential Evolution and TSP(Traveling salesman)

scikit-opt Swarm Intelligence in Python (Genetic Algorithm, Particle Swarm Optimization, Simulated Annealing, Ant Colony Algorithm, Immune Algorithm,A

郭飞 3.7k Jan 3, 2023
Genetic feature selection module for scikit-learn

sklearn-genetic Genetic feature selection module for scikit-learn Genetic algorithms mimic the process of natural selection to search for optimal valu

Manuel Calzolari 260 Dec 14, 2022