a container to communicate (changing) results via disk.
The data attribute is a dictionary (DataDict) which contains all
observed data, usually a list for each key. Any new container reads
previously saved data (with the same name) on initialization.
Before the data are saved, the old data are backupped under the current timestamp.
Use case example:
import cma.experimentation
# create or load 'sweep_data' results
res = cma.experimentation.Results('sweep_data')
# save data after each trial
for dim in dimensions:
res.backup() # in case we want fewer backups
for ...:
x, es = cma.fmin2(...)
res.data[dim] += [es.result.evaluations if 'ftarget' in es.result.stop()
else np.inf]
res.save(backup=False) # like this we can never lose data
Details: Saving/loading of nonfinite values with ast.literat_eval is
covered with the values_to_string parameters.
Some methods handle nested dictionaries, however it seems to be safer to use
tuples as keys in a flat dictionary or use different Results instances,
e.g. by dimension and/or popsize, like:
res = experimentation.Results('sweep_c_dim={}lam={}.format(dimension, popsize)
In particular .data.clean() for float keys does (currently) not work
with key tuples.
| Method | __getattr__ |
access Results.data directly from Results |
| Method | __init__ |
Undocumented |
| Method | backup |
backup saved data by making a file copy |
| Method | load |
load data from file, discard current data, see also update |
| Method | save |
save self.data to disk |
| Method | update |
Append data from filename to self.data. |
| Instance Variable | backup |
Undocumented |
| Instance Variable | data |
Undocumented |
| Instance Variable | filename |
Undocumented |
| Instance Variable | last |
Undocumented |
| Instance Variable | meta |
Undocumented |
| Method | _arrays |
return a flat list of (references to) all non-dicts in data. |
| Method | _backup0 |
append data to backup file, no easy to read back |
| Method | _load |
return dictionary from load json file with keys to int or float, if possible |
| Method | _value |
return "correct" value, doesn't work for nan |
| Method | _values |
replace certain values in lists with strings or vice versa. |
| Instance Variable | _extension |
Undocumented |
| Instance Variable | _values |
Undocumented |
Append data from filename to self.data.
To update self with a data dict instead a file, call
self.data.update(data).
Details: assumes a flat dict structure.
return a flat list of (references to) all non-dicts in data.
Traverses recursively down into dictionaries.
replace certain values in lists with strings or vice versa.
Values to be replaced are defined at instance creation in
_values_to_string_vals.
Details: this prevents ast.literal_eval to bail on, for example,
repr([1, 3, 'inf']), as 'inf' is just a string and will not be
evaluated.