def compute_prior(self):
     self.prior = GaussianLOTHypothesis.compute_prior(self)
     self.prior += sum(
         map(lambda x: normlogpdf(x, 0.0, CONSTANT_SD),
             self.CONSTANT_VALUES))
     self.posterior_score = self.prior + self.likelihood
     return self.prior
示例#2
0
 def __call__(self, *vals):
     """
         Must overwrite call in order to include the constants
     """
     vals = list(vals)
     vals.extend(self.CONSTANT_VALUES)
     return GaussianLOTHypothesis.__call__(self, *vals)
 def __call__(self, *vals):
     """
         Must overwrite call in order to include the constants
     """
     vals = list(vals)
     vals.extend(self.CONSTANT_VALUES)
     return GaussianLOTHypothesis.__call__(self, *vals)
 def toMaximize(fit_params):
     self.CONSTANT_VALUES = fit_params.tolist()  # set these
     # And return the original likelihood, which by get_function_responses above uses this
     constant_prior = sum(
         map(lambda x: normlogpdf(x, 0.0, CONSTANT_SD),
             self.CONSTANT_VALUES))
     return -(GaussianLOTHypothesis.compute_likelihood(self, data) +
              constant_prior)
示例#5
0
def run(*args):
    # starting hypothesis -- here this generates at random
    h0 = GaussianLOTHypothesis(grammar)

    # We store the top 100 from each run
    fs = FiniteBestSet(10, max=True, key="posterior_score")
    fs.add(mh_sample(h0, data, STEPS, skip=SKIP))

    return fs
示例#6
0
    def run(*args):

        # starting hypothesis -- here this generates at random
        h0 = GaussianLOTHypothesis(grammar,
                                   prior_temperature=PRIOR_TEMPERATURE)

        # We store the top 100 from each run
        pq = FiniteBestSet(100, max=True, key="posterior_score")
        pq.add(mh_sample(h0, data, STEPS, skip=SKIP))

        return pq
示例#7
0
 def to_maximize(fit_params):
     self.CONSTANT_VALUES = fit_params.tolist() # set these
     # And return the original likelihood, which by get_function_responses above uses this
     constant_prior = sum(map(lambda x: normlogpdf(x,0.0,CONSTANT_SD), self.CONSTANT_VALUES))
     return -(GaussianLOTHypothesis.compute_likelihood(self, data) + constant_prior)
示例#8
0
 def compute_prior(self):
     self.prior = GaussianLOTHypothesis.compute_prior(self)
     self.prior += sum(map(lambda x: normlogpdf(x,0.0,CONSTANT_SD), self.CONSTANT_VALUES))
     self.posterior_score = self.prior + self.likelihood
     return self.prior
示例#9
0
def make_h0(value=None):
    return GaussianLOTHypothesis(grammar, value=value)