Commit 1f28f6af authored by Jonas Šukys's avatar Jonas Šukys 💬

Fitscores and feedbacks are notw computed using means and medians.

parent eda06ef0
......@@ -1438,15 +1438,16 @@ class MatPlotLib (object):
for index, batch in enumerate (self.indices):
if self.replicates:
likelihoods = [chaininfo ['evaluations'] [name] if chaininfo is not None else float ('nan') for chaininfo in self.infos [index] ['infos']]
chain = numpy.nanargmax (likelihoods)
#likelihoods = [chaininfo ['evaluations'] [name] if chaininfo is not None else float ('nan') for chaininfo in self.infos [index] ['infos']]
#chain = numpy.nanargmax (likelihoods)
fitscores = [chaininfo ['infos'] [name] ['fitscore'] if chaininfo is not None else float ('nan') for chaininfo in self.infos [index] ['infos']]
fitscore [index] = fitscores [chain]
#fitscore [index] = fitscores [chain]
else:
likelihoods = self.infos [index] ['likelihoods']
chain = numpy.nanargmax (likelihoods)
#likelihoods = self.infos [index] ['likelihoods']
#chain = numpy.nanargmax (likelihoods)
fitscores = [chaininfo ['fitscore'] if chaininfo is not None else float ('nan') for chaininfo in self.infos [index] ['infos']]
fitscore [index] = fitscores [chain]
#fitscore [index] = fitscores [chain]
fitscore [index] = numpy.nanmean (fitscores)
upper [index] = numpy.nanmax (fitscores)
lower [index] = numpy.nanmin (fitscores)
......@@ -1466,7 +1467,7 @@ class MatPlotLib (object):
self.line_and_range (self.indices, -lower, -fitscore, -upper, logy=True, merged=0, linewidth=2, color=palette ['fitscore'])
# pylab.plot (self.indices, fitscore, linewidth=2, color=palette ['fitscore'], alpha=0.9)
pylab.ylabel ("negative fitscore")
pylab.axhline (threshold, color='forestgreen', linestyle='--', lw=5, alpha=0.9)
pylab.axhline (-threshold, color='forestgreen', linestyle='--', lw=5, alpha=0.9)
if scientific:
pylab.gca().ticklabel_format (axis='x', style='sci', scilimits=(-2, 2))
......@@ -1479,8 +1480,8 @@ class MatPlotLib (object):
Fitscores accross multiple concurrent chains of the sampler%(replicates)s.
Fitscore is the log of the average (over snapshots and particles)
normalized (with respect to maximum pdf value and the dimensions of the observations) posterior errors.
The solid line indicates the fitscore of the chain with the maximum likelihood estimate,
and the semi-transparent spreads indicate the minimum and the maximum fitscores
The solid line indicates the mean
and the semi-transparent spreads indicate the minimum and the maximum
accross multiple concurrent chains of the sampler.
The dashed green line indicates the threshold set in the adaptive PF likelihood.
""" % args
......@@ -1785,16 +1786,16 @@ class MatPlotLib (object):
print (' :: WARNING: NaN deviation at', chain, index)
deviation [chain] = float ('nan')
# deviation = numpy.sqrt (variance)
likelihoods = self.infos [index] ['likelihoods']
# likelihoods = self.infos [index] ['likelihoods']
# extent = numpy.abs (numpy.nanmax (likelihoods))
# extent = numpy.nanmax (likelihoods) - numpy.nanmin (likelihoods)
# extent = 4 * numpy.nanstd (likelihoods, ddof=1)
# extent = numpy.nanpercentile (likelihoods, 90) - numpy.nanpercentile (likelihoods, 10)
# extent = numpy.abs (numpy.nanpercentile (likelihoods, 90))
# deviation /= extent
arg = numpy.nanargmax (likelihoods)
means [index] = deviation [arg]
# means [index] = numpy.nanmedian (deviation)
# arg = numpy.nanargmax (likelihoods)
# means [index] = deviation [arg]
means [index] = numpy.nanmean (deviation)
lower [index] = numpy.nanmin (deviation)
# lower [index] = numpy.nanpercentile (deviation, percentile)
upper [index] = numpy.nanmax (deviation)
......@@ -1879,8 +1880,8 @@ class MatPlotLib (object):
Average (over dataset snapshots) standard deviations for the estimated marginal observational log-error
using the PF%(replicates)s.
The semi-transparent spread indicates the range (minimum and maximumum)
accross multiple concurrent chains of the sampler
and the solid line indicates the value of the chain with the largest estimated log-likelihood.
and the solid line indicates the mean
accross multiple concurrent chains of the sampler.
The solid thick gray line above the same line for a zero value reference
indicates the specified accuracy and
the dashed thick gray lines indicate the specified margins -
......
......@@ -148,8 +148,8 @@ class Sampler (object):
for name in names:
likelihoods [name] = [chaininfo ['evaluations'] [name] if chaininfo is not None else float ('nan') for chaininfo in info ["infos"]]
feedbacks = [likelihood.feedback (likelihoods) for likelihood in self.likelihoods]
args = {name : numpy.nanargmax (likelihoods [name]) for name in names}
feedback = {name : feedbacks [args [name]] [name] for name in names}
# args = {name : numpy.nanargmax (likelihoods [name]) for name in names}
feedback = {name : numpy.nanmedian ([feedback [name] for feedback in feedbacks]) for name in names}
info ["feedback"] = feedback
if self.informative:
info ['feedbacks'] = feedbacks
......@@ -164,8 +164,9 @@ class Sampler (object):
# for all other likelihoods, simply return all likelihood estimates across chains
else:
feedbacks = numpy.array ([likelihood.feedback (info ["likelihoods"]) for likelihood in self.likelihoods])
arg = numpy.nanargmax (info ["likelihoods"])
feedback = feedbacks [arg]
# arg = numpy.nanargmax (info ["likelihoods"])
# feedback = feedbacks [arg]
feedback = numpy.nanmedian (feedbacks)
info ["feedback"] = feedback
if self.informative:
info ['feedbacks'] = feedbacks
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment