A collection of commands for using COCO from Jupyter or IPython.
The main data structures used in COCO are DataSet, which
corresponds to data of one algorithm on one problem, and
DataSetList, which is for collections of DataSet
instances. Both classes are implemented in cocopp.pproc.
Examples:
Start by importing
cocopp:>>> import cocopp >>> cocopp.genericsettings.verbose = False # ensure to make below doctests work >>> def print_(*args, **kwargs): pass >>> cocopp.archives.bbob._print = print_ # avoid download notification
Load a data set, assign to variable
ds:>>> path = cocopp.archives.bbob.get(4) >>> print('ESC'); dsl = cocopp.load(path) # a dataset list # doctest:+ELLIPSIS ESC... >>> ds = dsl[0]Get some information on a
DataSetListinstance:>>> print(dsl) # doctest:+ELLIPSIS [DataSet(BIPOP-CMA-ES_hansen on f1 2-D), DataSet(BIPOP-CMA-ES... >>> dsl.info() 144 data set(s) Algorithm(s): BIPOP-CMA-ES_hansen 24 Functions with IDs 1-24 Dimension(s): 2, 3, 5, 10, 20, 40 Max evals: [1625595, 2349823, 3114271, 5884514, 12102699, 36849608]
Get some information on a
DataSetinstance:>>> print(ds) DataSet(BIPOP-CMA-ES_hansen on f1 2-D) >>> ds.info() Algorithm: BIPOP-CMA-ES_hansen Function ID: 1 Dimension DIM = 2 Number of trials: 15 Final target Df: 1e-08 min / max number of evals per trial: 224 / 333 evals/DIM: best 15% 50% 85% max | ERT/DIM nsucc ---Df---|-----------------------------------------|---------------- 1.0e+03 | 0 0 0 0 0 | 0.5 15 1.0e+01 | 0 0 2 8 10 | 2.9 15 1.0e-01 | 8 13 22 38 52 | 24.2 15 1.0e-03 | 34 48 56 74 77 | 58.2 15 1.0e-05 | 64 70 89 100 102 | 86.1 15 1.0e-08 | 112 116 128 150 166 | 130.9 15
| Class | |
This class is superseded by cocoex.ExperimentRepeater for its main usecase, |
| Function | info |
Display more info on an instance of DatasetList. |
| Function | load |
[currently broken when further used within cocopp, see load2] Create a DataSetList instance from a file or folder. |
| Function | load2 |
[WIP] return a DataSetList or a dict of dict of DataSetLists. |
| Function | systeminfo |
Display information on the system. |
| Function | true |
return number of actually conducted trials for DataSet ds |
| Function | _pickle |
Pickle a DataSetList. |
[currently broken when further used within cocopp, see load2] Create a DataSetList instance from a file or folder.
Input argument filename can be a single info file name, a single pickle filename or a folder name. In the latter case, the folder is browsed recursively for info or pickle files.
Details: due to newly implemented side effects when data are read in,
the returned data set list may not work anymore when used with plotting
functions of the cocopp module, see also load2.
[WIP] return a DataSetList or a dict of dict of DataSetLists.
args is a string or a list of strings passed to
cocopp.official_archives.all.get_extended to determine the desired
data sets which can also come from a local folder or a zip-file.
keep and remove are callables taking a cocopp.pproc.DataSet class
instance as argument and return a bool according to which data sets
are filtered (usually based on the funcId attribute, see below
example). In case, remove takes precedent. When keep is None all
elements are kept unless removed.
return a DataSetList if either flat_list or flat_list is None
and args describes a single algorithm/experiment, return otherwise a
dict of dict with dimension and pathname as keys, respectively.
Examples:
# Get a single `DataSet`, here for F1 in 20-D
>> ds = cocopp.load2('nelder!').by('dim')[20].by('funcId')[1][0]
# get 31 data sets, takes ~3 minutes at first ever loading
>> ddsl31 = load('bbob/2009/*')
>> assert sorted(ddsl31) == [2, 3, 5, 10, 20, 40], ddsl
>> assert len(ddsl31[3]) == 31, ddsl
>>> import cocopp >>> def pprldmany(dsl): ... print('OK') # circumvent output checking ... with cocopp.toolsdivers.InfolderGoneWithTheWind(): ... cocopp.compall.pprldmany.main(dsl) # writes pprldmany_default.* ... >>> _, ddsl = (print('OK'), # circumvent output checking ... cocopp.load2('bbob/2009/B*', ... remove=lambda ds: ds.funcId in [1, 5])) # doctest:+ELLIPSIS OK... >>> assert sorted(ddsl) == [2, 3, 5, 10, 20, 40], sorted(ddsl) >>> assert all([len(ddsl[i]) == 3 for i in ddsl]), ddsl # 3 algorithms >>> assert len(list(ddsl[3].values())[0]) == 22, list(ddsl[3].values())[0] >>> pprldmany(ddsl[2]) # doctest:+ELLIPSIS OK...