Exemplo n.º 1
0
 def __init__(self,
              output_path,
              docs,
              vocab,
              topic_count=20,
              alpha=0.1,
              beta=0.1,
              total_iteration=1000):
     self.output_path = output_path
     self.vocab = vocab
     self.k, self.alpha, self.beta = topic_count, alpha, beta
     self.model = FixedTopicModel(topic_count, len(vocab), alpha, beta)
     for doc in docs:
         self.model.add_new_document(doc)
     self.sampler = BaseSampler(self.model, total_iteration)
Exemplo n.º 2
0
class LDARunner:
  def __init__(self, output_path, docs,
      vocab, topic_count = 20, alpha = 0.1, beta = 0.1,
      total_iteration=1000):
    self.output_path = output_path
    self.vocab = vocab
    self.k, self.alpha, self.beta = topic_count, alpha, beta
    self.model = FixedTopicModel(topic_count, len(vocab), alpha, beta)
    for doc in docs:
      self.model.add_new_document(doc)
    self.sampler = BaseSampler(self.model, total_iteration)

  def run(self):
    self.sampler.inference()
    save_topic_matrix(self.model, self.vocab, self.output_path)
Exemplo n.º 3
0
 def __init__(self, output_path, docs,
     vocab, topic_count = 20, alpha = 0.1, beta = 0.1,
     total_iteration=1000):
   self.output_path = output_path
   self.vocab = vocab
   self.k, self.alpha, self.beta = topic_count, alpha, beta
   self.model = FixedTopicModel(topic_count, len(vocab), alpha, beta)
   for doc in docs:
     self.model.add_new_document(doc)
   self.sampler = BaseSampler(self.model, total_iteration)
Exemplo n.º 4
0
class LDARunner:
    def __init__(self,
                 output_path,
                 docs,
                 vocab,
                 topic_count=20,
                 alpha=0.1,
                 beta=0.1,
                 total_iteration=1000):
        self.output_path = output_path
        self.vocab = vocab
        self.k, self.alpha, self.beta = topic_count, alpha, beta
        self.model = FixedTopicModel(topic_count, len(vocab), alpha, beta)
        for doc in docs:
            self.model.add_new_document(doc)
        self.sampler = BaseSampler(self.model, total_iteration)

    def run(self):
        self.sampler.inference()
        save_topic_matrix(self.model, self.vocab, self.output_path)