An artificial bee colony implementation in Python
Project description
Honeybee
An artificial bee colony implementation in Python
Installation
To install with pip
:
pip install honeybee
Usage
To use, first install the package as above, then define a function that you wish to optimize. This can be a simple mathematical formula, or something that calls a complicated model training routine. The important thing is that it depends on hyperparameters that can be passed to the function, and returns a fitness measure that will be maximized by the algorithm:
def my_func(**params):
""" Implements Rastrigin's function of two inputs. """
x = [v for v in params.values()]
return 20 + sum([a**2 - 10*cos(2*np.pi*a) for a in x])
Next define the ranges of parameters over which you wish to optimize:
params = {'x1': (-5.12, 5.12),
'x2': (-5.12, 5.12)}
Finally, initialize the colony and fit the objective function:
my_colony = Colony(my_func, params, num_bees=10)
my_colony.fit()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
honeybee-0.1.0a3.tar.gz
(3.3 kB
view hashes)
Built Distribution
Close
Hashes for honeybee-0.1.0a3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b56a5cf3f65f760f98b197619bbf83dddacd5f8a52730d2ef903fcd1e4314526 |
|
MD5 | 30593df1f55be32c10d0bca1331073d1 |
|
BLAKE2b-256 | 2b135c6fc792e21cfc9ee2ad019ddd1bc3dd0dd11309e38b799e009b9e80785e |