edolab
A command line tool for running experiments with
edo.
Installation
edolab is pip-installable:
$ python -m pip install edolab
Usage
Experiment scripts
To use edolab, you will need to write a Python script configuring the
parameters of your experiment.
Required parameters
fitness: A function that takes (at least) anedo.Individualinstance to be used as the fitness function byedodistributions: A list ofedo.distribution.Distributionsubclasses that will be used to create theedo.Familyinstances foredo- Variable assignments for all of the essential arguments in
edo.DataOptimiserexcept forfamilies
Optional parameters
root: A directory to which data should be written (and summarised from)processes: A number of processes foredoto use when calculating population fitness- Custom column distribution classes should be defined in the script
- If you wish to use a custom
stopordwindlemethod then define a subclass ofedo.DataOptimiserand assign that class to a variable calledoptimiser - Any keyword arguments to pass to
fitnessor thestopanddwindlemethods should be assigned to the corresponding<func>_kwargsvariable.
An example of such a script would be something like this:
""" /path/to/experiment/script.py """
import edo
import numpy as np
from edo.distributions import Uniform
class CustomOptimiser(edo.DataOptimiser):
""" This is an optimiser with custom stopping and dwindling methods. """
def stop(self, tol):
""" Stop if the median fitness is less than `tol` away from zero. """
self.converged = abs(np.median(self.pop_fitness)) < tol
def dwindle(self, rate):
""" Cut the mutation probability in half every `rate` generations. """
if self.generation % rate == 0:
self.mutation_prob /= 2
def fitness(individual, size, seed=0):
""" Randomly sample `size` values from an individual and return the
minimum. """
np.random.seed(seed)
values = individual.dataframe.values.flat
sample = np.random.choice(values, size=size)
return min(sample)
class NegativeUniform(Uniform):
""" A copy that only takes negative values. """
name = "NegativeUniform"
param_limits = {"bounds": [-1, 0]}
hard_limits = {"bounds": [-100, 0]}
size = 5
row_limits = [1, 5]
col_limits = [1, 2]
max_iter = 3
best_prop = 0.5
mutation_prob = 0.5
Uniform.param_limits["bounds"] = [0, 1]
distributions = [Uniform, NegativeUniform]
optimiser = CustomOptimiser
fitness_kwargs = {"size": 3}
stop_kwargs = {"tol": 1e-3}
dwindle_kwargs = {"rate": 10}
For more details on the parameters of edo, see its documentation:
https://edo.readthedocs.io
Running the experiment
Then, to run an experiment with this script do the following:
$ edolab run /path/to/experiment/script.py
Summarising the experiment
And to summarise the data (for easy transfer):
$ edolab summarise /path/to/experiment/script.py
For further details on the commands, use the --help flag on the run and
summarise commands.
A note on reproducibility
It is highly recommended that you use a virtual environment when using edo in
or outside of this command line tool as edo uses pickle to store various
objects created in a run that may not be retrievable with a different version of
Python.
Contributing
This tool has been made to be pretty bare and could use some padding out. If you'd like to contribute then make a fork and clone the repository locally:
$ git clone https://github.com/<your-username>/edolab.git
Install the package and replicate the conda environment (or install the
development dependencies manually):
$ cd edolab
$ python setup.py develop
$ conda env create -f environment.yml
$ conda activate edolab-dev
Make your changes and write tests to go with them, ensuring they pass:
$ python -m pytest --cov=edolab --cov-fail-under=100 tests
Commit, push to your fork and open a pull request!
Metadata
Release files for edolab 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| edolab-0.0.6.tar.gz | 9.1 kB | Without provenance | Details for edolab-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| edolab-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for edolab-0.0.6-py3-none-any.whl |
Total release size: 17.4 kB
Release files / edolab-0.0.6.tar.gz
| Download URL | edolab-0.0.6.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bfd91aee353b99732f152bf5dee424ce92e7e59d489abcf9a7dbbbb874dc1046
|
|
BLAKE2b-256 checksum How to use checksums |
8f0d577f5dbd1e17aea7c64a1097d2194cd66c39e3ba9344c0b6900e0ec8e4d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3
|
Release files / edolab-0.0.6-py3-none-any.whl
| Download URL | edolab-0.0.6-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e2613d855885068eefe8c111fab3f9d8981cdb9c6246af4efc7f60dce6366a89
|
|
BLAKE2b-256 checksum How to use checksums |
c95118906f1182ae34bdd34728ef552761dcff5c250db5d729232c0bff3aa34c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3
|
Security for edolab 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.