This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| lda_model[corpus[0]] # corpus[0] means the first document. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for i,topic in lda_model.show_topics(formatted=True, num_topics=num_topics, num_words=10): | |
| print(str(i)+": "+ topic) | |
| print() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from gensim import corpora, models | |
| # list_of_list_of_tokens = [["a","b","c"], ["d","e","f"]] | |
| # ["a","b","c"] are the tokens of document 1, ["d","e","f"] are the tokens of document 2... | |
| dictionary_LDA = corpora.Dictionary(list_of_list_of_tokens) | |
| dictionary_LDA.filter_extremes(no_below=3) | |
| corpus = [dictionary_LDA.doc2bow(list_of_tokens) for list_of_tokens in list_of_list_of_tokens] | |
| num_topics = 20 | |
| %time lda_model = models.LdaModel(corpus, num_topics=num_topics, \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from gensim import corpora, models | |
| # list_of_list_of_tokens = [["a","b","c"], ["d","e","f"]] | |
| # ["a","b","c"] are the tokens of document 1, ["d","e","f"] are the tokens of document 2... | |
| dictionary_LDA = corpora.Dictionary(list_of_list_of_tokens) | |
| dictionary_LDA.filter_extremes(no_below=3) | |
| corpus = [dictionary_LDA.doc2bow(list_of_tokens) for list_of_tokens in list_of_list_of_tokens] | |
| num_topics = 20 | |
| %time lda_model = models.LdaModel(corpus, num_topics=num_topics, \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from gensim import corpora, models | |
| dictionary_LDA = corpora.Dictionary(list_of_list_of_tokens) | |
| dictionary_LDA.filter_extremes(no_below=3) | |
| corpus = [dictionary_LDA.doc2bow(list_of_tokens) for list_of_tokens in list_of_list_of_tokens] | |
| num_topics = 20 | |
| %time lda_model = models.LdaModel(corpus, num_topics=num_topics, \ | |
| id2word=dictionary_LDA, \ | |
| passes=4, alpha=[0.01]*num_topics, \ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dictionary = {} | |
| for i,row in data.iterrows(): | |
| dictionary[row['column_1']] = row['column_2'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data.groupby('column_1')['column_2'].apply(sum).reset_index() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data.merge(other_data, on=['column_1', 'column_2', 'column_3']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pd.plotting.scatter_matrix(data, figsize=(12,8)) |