Skip to content

Commit

Permalink
Fix leaveOneOut algorithm for when averaging is false
Browse files Browse the repository at this point in the history
  • Loading branch information
connie committed Jul 26, 2016
1 parent d65382c commit 3c749de
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions testing/evaluateKinetics.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,23 @@ def getKineticsLeaveOneOut(family, averaging=True):
exactKinetics={}
approxKinetics={}

rootTemplate = family.getRootTemplate()

for entryKey in family.rules.entries.keys():
template = family.retrieveTemplate(entryKey.split(';'))
exactKineticsData, exactKineticsEntry=family.rules.estimateKinetics(template)
if exactKineticsData.comment:
# This means it was an averaged node so skip
exactKineticsEntry=family.rules.getRule(template) # fetch the best matched rule
if exactKineticsEntry.rank == 0:
# Skip rank zero entries, because they are replaced by averaged values
# during model generation
continue

exactKineticsData = exactKineticsEntry.data
if exactKineticsData.comment:
if 'training' not in exactKineticsData.comment:
# Averaged nodes have kinetics data comments, so skip them unless
# They were created from training reactions
continue

exactKinetics[entryKey] = exactKineticsData

if averaging:
Expand All @@ -111,7 +121,12 @@ def getKineticsLeaveOneOut(family, averaging=True):
# This takes significanty less time to run, but is not a true validation of the data,
# it is just testing our kinetics selection algorithm

originalEntry = family.rules.entries(entryKey)
# Skip the top node in this scheme, because nothing can predict it if removed

if template == rootTemplate:
continue

originalEntry = family.rules.entries[entryKey]
family.rules.entries.pop(entryKey)
approxKinetics[entryKey], approxKineticsEntry=family.rules.estimateKinetics(template)
# Re-add the data back into the original family
Expand Down

0 comments on commit 3c749de

Please sign in to comment.