Examples
import cma
es = cma.CMAEvolutionStrategy(...)
logger = cma.CMADataLogger().register(es)
while not es.stop():
...
logger.add() # add can also take an argument
logger.plot() # or a short cut can be used:
cma.plot() # plot data from logger with default name
logger2 = cma.CMADataLogger('just_another_filename_prefix').load()
logger2.plot()
logger2.disp()
import cma
from matplotlib.pylab import *
res = cma.fmin(cma.Fcts.sphere, rand(10), 1e-0)
logger = res[-1] # the CMADataLogger
logger.load() # by "default" data are on disk
semilogy(logger.f[:,0], logger.f[:,5]) # plot f versus iteration, see file header
show()
Details
After loading data, the logger has the attributes xmean, xrecent,
std, f, D and corrspec corresponding to xmean,
xrecentbest, stddev, fit, axlen and axlencorr
filename trails.
|
|
|
|
|
|
|
|
register(self,
es,
append=None,
modulo=None)
register a CMAEvolutionStrategy instance for logging,
append=True appends to previous data logged under the same name,
by default previous data are overwritten. |
source code
|
|
|
|
initialize(self,
modulo=None)
reset logger, overwrite original files, modulo: log only every modulo call |
source code
|
|
|
|
|
|
|
add(self,
es=None,
more_data=[],
modulo=None)
append some logging data from CMAEvolutionStrategy class instance es,
if number_of_times_called % modulo equals to zero, never if modulo==0. |
source code
|
|
|
|
|
|
|
save_to(self,
nameprefix,
switch=False)
saves logger data to a different set of files, for
switch=True also the loggers name prefix is switched to
the new value |
source code
|
|
|
|
select_data(self,
iteration_indices)
keep only data of iteration_indices |
source code
|
|
|
|
plot(self,
fig=None,
iabscissa=1,
iteridx=None,
plot_mean=False,
foffset=1e-19,
x_opt=None,
fontsize=9)
plot data from a CMADataLogger (using the files written
by the logger). |
source code
|
|
|
|
plot_all(self,
fig=None,
iabscissa=1,
iteridx=None,
foffset=1e-19,
x_opt=None,
fontsize=9)
plot data from a CMADataLogger (using the files written by the logger). |
source code
|
|
|
|
|
|
|
|
|
|
| plot_mean(self,
iabscissa=1,
x_opt=None,
annotations=None) |
source code
|
|
|
|
| plot_xrecent(self,
iabscissa=1,
x_opt=None,
annotations=None) |
source code
|
|
|
|
plot_correlations(self,
iabscissa=1)
spectrum of correlation matrix and largest correlation |
source code
|
|
|
|
|
|
|
_enter_plotting(self,
fontsize=9)
assumes that a figure is open |
source code
|
|
|
|
|
|
|
|
|
|
_plot_x(self,
iabscissa=1,
x_opt=None,
remark=None,
annotations=None)
If x_opt is not None the difference to x_opt is plotted
in log scale |
source code
|
|
|
|
downsampling(self,
factor=10,
first=3,
switch=True,
verbose=True)
rude downsampling of a CMADataLogger data file by factor,
keeping also the first first entries. This function is a
stump and subject to future changes. Return self. |
source code
|
|
|
|
|
|
|
|
|
Inherited from object:
__delattr__,
__format__,
__getattribute__,
__hash__,
__new__,
__reduce__,
__reduce_ex__,
__repr__,
__setattr__,
__sizeof__,
__str__,
__subclasshook__
|