def dt_comp(self,sampled_topics): """ Compute document-topic matrix from sampled_topics. """ samples = sampled_topics.shape[0] dt = np.zeros((self.D,self.K,samples)) for s in xrange(samples): dt[:,:,s] = samplers.dt_comp(self.docid, sampled_topics[s,:], self.N, self.K, self.D, self.alpha) return dt
def dt_comp(self, sampled_topics): """ Compute document-topic matrix from sampled_topics. """ samples = sampled_topics.shape[0] dt = np.zeros((self.D, self.K, samples)) for s in xrange(samples): dt[:, :, s] = samplers.dt_comp(self.docid, sampled_topics[s, :], self.N, self.K, self.D, self.alpha) return dt
def query(self,query_samples): """ Query docs with query_samples number of Gibbs sampling iterations. """ self.sampled_topics = np.zeros((self.samples,self.N), dtype = np.int) for s in xrange(self.samples): self.sampled_topics[s,:] = samplers.sampler_query(self.docid, self.tokens, self.topic_seed, np.ascontiguousarray(self.tt[:,:,s], dtype=np.float), self.N, self.K, self.D, self.alpha, query_samples) print("Sample %d queried" % s) self.dt = np.zeros((self.D,self.K,self.samples)) for s in xrange(self.samples): self.dt[:,:,s] = samplers.dt_comp(self.docid,self.sampled_topics[s,:], self.N, self.K, self.D, self.alpha)
def query(self, query_samples): """ Query docs with query_samples number of Gibbs sampling iterations. """ self.sampled_topics = np.zeros((self.samples, self.N), dtype=np.int) for s in xrange(self.samples): self.sampled_topics[s, :] = samplers.sampler_query( self.docid, self.tokens, self.topic_seed, np.ascontiguousarray(self.tt[:, :, s], dtype=np.float), self.N, self.K, self.D, self.alpha, query_samples) print("Sample %d queried" % s) self.dt = np.zeros((self.D, self.K, self.samples)) for s in xrange(self.samples): self.dt[:, :, s] = samplers.dt_comp(self.docid, self.sampled_topics[s, :], self.N, self.K, self.D, self.alpha)