Esempio n. 1
0
 def sampler_create(self, group=None):
     probs = (self.betas * self.alpha).tolist()
     if group is not None:
         for i, count in group.counts.iteritems():
             probs[i] += count
     probs.append(self.beta0 * self.alpha)
     return sample_dirichlet(probs)
Esempio n. 2
0
 def init(self, shared, group=None):
     self.values = []
     post = []
     alpha = shared.alpha
     counts = {} if group is None else group.counts
     for value, beta in shared.betas.iteritems():
         self.values.append(value)
         post.append(beta * alpha + counts.get(value, 0))
     if shared.beta0 > 0:
         self.values.append(OTHER)
         post.append(shared.beta0 * alpha)
     self.probs = sample_dirichlet(post)
Esempio n. 3
0
 def init(self, shared, group=None):
     self.values = []
     post = []
     alpha = shared.alpha
     counts = {} if group is None else group.counts
     for value, beta in shared.betas.iteritems():
         self.values.append(value)
         post.append(beta * alpha + counts.get(value, 0))
     if shared.beta0 > 0:
         self.values.append(OTHER)
         post.append(shared.beta0 * alpha)
     self.probs = sample_dirichlet(post)
Esempio n. 4
0
 def init(self, shared, group=None):
     if group is None:
         self.ps = sample_dirichlet(shared.alphas)
     else:
         self.ps = sample_dirichlet(group.counts + shared.alphas)
Esempio n. 5
0
 def init(self, shared, group=None):
     if group is None:
         self.ps = sample_dirichlet(shared.alphas)
     else:
         self.ps = sample_dirichlet(group.counts + shared.alphas)