Last active
August 29, 2015 14:07
-
-
Save cmd-ntrf/dab979c9d9cde16aff4d to your computer and use it in GitHub Desktop.
DEAP example of logbook merging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
from deap import tools | |
logbook1 = tools.Logbook() | |
logbook2 = tools.Logbook() | |
logbook3 = tools.Logbook() | |
# Filling the logbooks [...] | |
logbook_list = [logbook1, logbook2, logbook3] | |
# Resulting logbook | |
aggregate = tools.Logbook() | |
# We identify the fields we want to merge or aggregate | |
fields = ['avg', 'min', 'max'] | |
# We suppose every logbook as the same number of entries | |
nentry = len(logbook1) | |
for i in range(nentry): | |
record = {} | |
for field in fields: | |
record[field] = numpy.mean([logbook[i][field] for logbook in logbook_list]) | |
aggregate.record(**record) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment