-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimised show_topics #1028
Optimised show_topics #1028
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove duplicate code please
@@ -800,15 +800,24 @@ def show_topics(self, num_topics=10, num_words=10, log=False, formatted=True): | |||
chosen_topics = sorted_topics[:num_topics // 2] + sorted_topics[-num_topics // 2:] | |||
|
|||
shown = [] | |||
|
|||
topic = self.state.get_lambda() | |||
for i in chosen_topics: | |||
if formatted: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too much code duplication
Just add an extra if formatted
block in the end that changes formatting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, that was quite stupid of me 💩
Will fix!
@tmylk , removed duplicate code. |
Is there a performance improvement with |
Yeah, with the old method and 5 topics for the |
hmm, that doesn't agree with the original report of
|
Could it maybe be because of the number of topics? Will increase number of topics and see what the difference is like. I only have 5 topics. |
Yes, let's test the reported case |
I got a fairly significant improvement (20 times faster) with 500 topics (vocab is smaller though, len is 44143). For the old method:
For the optimised method:
|
Thanks a lot for the improvement! |
😄 |
Possible solution to #1006 .
@tmylk could you review?