Skip to main content

image PyPI

EC-KitY is a Python tool kit for doing evolutionary computation, and it is scikit-learn compatible.

Currently we have implemented Genetic Algorithm (GA) and tree-based Genetic Programming (GP), but EC-KitY will grow!

Join the community section

EC-KitY is:

  • A comprehensive toolkit for running evolutionary algorithms
  • Written in Python
  • Can work with or without scikit-learn, i.e., supports both sklearn (ML) and non-sklearn (basic) modes
  • Designed with modern software engineering in mind
  • Designed to support all popular EC paradigms (GA, GP, ES, coevolution, multi-objective, etc').

Dependencies

The minimal Python Version for EC-KitY is Python 3.8

The dependencies of our base package are described in requirements.txt In addition, the dependencies of the ML mode are described in requirements-ml.txt

User installation

pip install eckity

Documentation

API is available here

(Work in progress - some modules and functions are not documented yet.)

Tutorials

The tutorials are available here, walking you through running EC-KitY both in sklearn mode and in non-sklearn mode.

Examples

More examples are in the examples folder. All you need to do is define a fitness-evaluation method, through a SimpleIndividualEvaluator sub-class. You can run the examples with ease by opening this colab notebook.

Basic example (no sklearn)

You can run an EA with just 3 lines of code. The problem being solved herein is simple symbolic regression.

Additional information on this problem can be found in the Symbolic Regression Tutorial.

from eckity.subpopulation import Subpopulation
from eckity.algorithms import SimpleEvolution
from eckity.base.untyped_functions import f_add, f_sub, f_mul, f_div
from eckity.creators import FullCreator
from eckity.genetic_operators import SubtreeCrossover, SubtreeMutation
from examples.treegp.basic_mode.symbolic_regression import SymbolicRegressionEvaluator

algo = SimpleEvolution(
    Subpopulation(
        SymbolicRegressionEvaluator(),
        creators=FullCreator(
            terminal_set=['x', 'y', 'z'],
            function_set=[f_add, f_sub, f_mul, f_div]
        ),
        operators_sequence=[SubtreeCrossover(), SubtreeMutation()]
    )
)
algo.evolve()
print(f'algo.execute(x=2,y=3,z=4): {algo.execute(x=2, y=3, z=4)}')

Example with sklearn

The problem being solved herein is the same problem, but in this case we also involve sklearn compatability - a core feature of EC-KitY. Additional information for this example can be found in the Sklearn Symbolic Regression Tutorial.

A simple sklearn-compatible EA run:

from sklearn.datasets import make_regression
from sklearn.metrics import mean_absolute_error
from sklearn.model_selection import train_test_split

from eckity.algorithms.simple_evolution import SimpleEvolution
from eckity.base.untyped_functions import f_add, f_div, f_mul, f_sub
from eckity.creators.gp_creators.full import FullCreator
from eckity.genetic_encodings.gp.tree.utils import create_terminal_set
from eckity.genetic_operators import SubtreeCrossover, SubtreeMutation
from eckity.sklearn_compatible.regression_evaluator import RegressionEvaluator
from eckity.sklearn_compatible.sk_regressor import SKRegressor
from eckity.subpopulation import Subpopulation

X, y = make_regression(n_samples=100, n_features=3)
terminal_set = create_terminal_set(X)
function_set = [f_add, f_sub, f_mul, f_div]

algo = SimpleEvolution(
    Subpopulation(
        RegressionEvaluator(),
        creators=FullCreator(
            terminal_set=terminal_set,
            function_set=function_set
        ),
        operators_sequence=[SubtreeCrossover(), SubtreeMutation()]
    )
)
regressor = SKRegressor(algo)

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
regressor.fit(X_train, y_train)
print('MAE on test set:', mean_absolute_error(y_test, regressor.predict(X_test)))

Feature comparison

Here's a comparison table. The full paper is available here. image

Authors

Moshe Sipper, Achiya Elyasaf, Itai Tzruia, Tomer Halperin

Citation

Citations are always appreciated 😊:

@article{eckity2023,
author = {Moshe Sipper and Tomer Halperin and Itai Tzruia and Achiya Elyasaf},
title = {{EC-KitY}: Evolutionary computation tool kit in {Python} with seamless machine learning integration},
journal = {SoftwareX},
volume = {22},
pages = {101381},
year = {2023},
url = {https://www.sciencedirect.com/science/article/pii/S2352711023000778},
}

@misc{eckity2022git,
    author = {Sipper, Moshe and Halperin, Tomer and Tzruia, Itai and  Elyasaf, Achiya},
    title = {{EC-KitY}: Evolutionary Computation Tool Kit in {Python}},
    year = {2022},
    publisher = {GitHub},
    journal = {GitHub repository},
    howpublished = {\url{https://www.eckity.org/} }
}

Sample repos using EC-KitY

Download files

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

Source Distribution

eckity-0.4.2.tar.gz (74.2 kB view details)

Uploaded Source

Built Distribution

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

eckity-0.4.2-py3-none-any.whl (134.1 kB view details)

Uploaded Python 3

File details

Details for the file eckity-0.4.2.tar.gz.

File metadata

  • Download URL: eckity-0.4.2.tar.gz
  • Upload date:
  • Size: 74.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for eckity-0.4.2.tar.gz
Algorithm Hash digest
SHA256 63e8757d9a17b89531d8f700fa6b5d315fb1bcba6dcb656b3db4fc3dfcca2863
MD5 a9162432c0dd6990deb1c8d963f8f9af
BLAKE2b-256 4db856d249e01e523039daac38bbf5991bdcb393cdb14bee39926ff04d3dcbee

See more details on using hashes here.

File details

Details for the file eckity-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: eckity-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 134.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for eckity-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f53bbb0b1316837f83c394170195fac8bc2dcb44861f320487727055de9c68b4
MD5 e99de77e871cd1c5cd4a7bb80e7ff755
BLAKE2b-256 4f7b87c7da269ceb9fede2c0fc0f2dc0471799d621da0b805cd7a81007be6129

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4.2 This release

2 files

0.4.1

2 files

0.4.0

2 files

0.3.4

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

2 files

Supported by

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