Coder Social home page Coder Social logo

hmm-lda's People

Contributors

katsuya94 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hmm-lda's Issues

Redundant looping in calculating "num_same_words.." counts

Hi,
I was trying to re-implement your python code to c++ so that it can handle larger data. While doing so I realized that the function run_counts() is the main performance bottleneck. Specifically the loops where you compute
self.num_same_words_assigned_to_topic = [self.count_num_same_words_assigned_to_topic(word) for word in xrange(self.vocab_size)]
count_num_same_words_assigned_to_topic(word) is a 2D loop of documents * topics and it is called vocab_size times (one time for each word in the vocab. Calling this function for each word is redundant because it can be done in documents * topics iterations like so

for(int i = 0; i < n_documents; i++) {
	doc_size = documents[i].size();
	for(int j = 0; j < doc_size; j++) {
		word = documents[i][j];
		if(class_assignments[i][j] == 0)
			num_same_words_assigned_to_topic[word][topic_assignments[i][j]] += 1;
	}
}

Kindly note that this is a c++ code snippet but this can be very easily ported to python. This should give a good speed improvement in the overall performance. Correct me if I'm doing something wrong.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.