EvoDAG

Evolving Directed Acyclic Graphs: Semantic Genetic Programming for Classification and Regression

EvoDAG is a Python library that learns a classifier or a regressor with Genetic Programming (GP). It keeps every individual it ever creates in a table, and each one is a node of a directed acyclic graph that points at the nodes it was built from. The result of a run is not a tree but a small graph in which many nodes share the same inputs.

What sets it apart from textbook GP is how a new individual is made. Every individual is described by its semantics, the vector of values it produces on the training examples. When a function (a sum, a product, a Naive Bayes classifier, …) combines existing individuals, EvoDAG also fits the coefficients of the combination by ordinary least squares so that the result is as close as possible to the target vector. The genetic operator therefore acts at the root of the new individual, and only the examples (not the whole expression) are evaluated. The How it works page walks through the method.

You use it like any scikit-learn estimator: fit(X, y), predict(X) and score(X, y), and it works in pipelines and in grid searches. A single run can overfit, so the usual way to use EvoDAG is an ensemble of independent runs, each one stopped early on its own validation split. A command line interface (EvoDAG-params, EvoDAG-train, EvoDAG-predict and EvoDAG-utils) covers the same ground for people who prefer to work with files.

A first example

The snippet below trains an ensemble of five models on a small synthetic problem and predicts the training set. EnsembleClassifier(EvoDAGClassifier()) is EvoDAG’s ensemble in scikit-learn form; EvoDAGClassifier alone is one model. They need scikit-learn, which is an optional dependency: pip install 'EvoDAG[sklearn]'. The example is deliberately tiny so that it runs in a few seconds; the real defaults use much larger populations (see Parameters).

import numpy as np
from EvoDAG import EnsembleClassifier, EvoDAGClassifier

rng = np.random.RandomState(0)
X = rng.randn(200, 4)
y = (X[:, 0] + X[:, 1] ** 2 > 1).astype(int)

tiny = EvoDAGClassifier(popsize=100, early_stopping_rounds=100)
model = EnsembleClassifier(tiny, n_estimators=5, random_state=0).fit(X, y)
hy = model.predict(X)
print("accuracy on the training set:", model.score(X, y))

Where to go next

If you want to … read
install the package Install
use it from Python with the scikit-learn classes: classification, regression, ensembles Python
use EvoDAG’s own classes (EvoDAGE, the engine) Native API
train and predict from the shell Command line
understand the method How it works
know more about the selection heuristics Selection
tune it Parameters
see how well it does Performance
cite it Citing

EvoDAG is released under the Apache 2.0 license. The source code, the issue tracker and the releases are on GitHub.