Module Expr Str ImportFrom alias ImportFrom alias ImportFrom alias alias ImportFrom alias alias ImportFrom alias Assign NameStore Num Assign NameStore Num Assign NameStore Num Assign NameStore Num FunctionDef arguments args NameParam NameParam NameParam defaults body For TupleStore NameStore NameStore Call NameLoad AttributeLoad NameLoad attr body Expr Call NameLoad BinOpMod Str NameLoad Expr Call NameLoad Call AttributeLoad Str attr ListComp SubscriptLoad NameLoad Index NameLoad comprehension NameStore SubscriptLoad Call AttributeLoad NameLoad attr Slice BinOpSub UnaryOpUSub NameLoad Num Num Expr Call NameLoad decorator_list Expr Call NameLoad Str Assign NameStore Call NameLoad Assign NameStore Call NameLoad keyword NameLoad keyword Num keyword TupleLoad Str Str Str Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Slice NameLoad Expr Call NameLoad BinOpMod Str BinOpSub Call NameLoad NameLoad Expr Call NameLoad Str Assign NameStore Call NameLoad keyword Num keyword Num keyword NameLoad keyword Str Assign NameStore Call NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad BinOpMod Str BinOpSub Call NameLoad NameLoad Expr Call NameLoad Str Assign NameStore Call NameLoad keyword Num keyword Num keyword NameLoad keyword Str Assign NameStore Call NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad BinOpMod Str BinOpSub Call NameLoad NameLoad Expr Call NameLoad BinOpMod Str TupleLoad NameLoad NameLoad Assign NameStore Call NameLoad Assign NameStore Call AttributeLoad Call NameLoad keyword NameLoad keyword Num keyword Num keyword Num attr NameLoad Expr Call NameLoad BinOpMod Str BinOpSub Call NameLoad NameLoad Expr Call NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr Expr Call NameLoad NameLoad NameLoad NameLoad Expr Call NameLoad BinOpMod Str TupleLoad NameLoad NameLoad Assign NameStore Call NameLoad keyword NameLoad keyword Num keyword Str keyword Num keyword Num Assign NameStore Call NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad BinOpMod Str BinOpSub Call NameLoad NameLoad Expr Call NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr Expr Call NameLoad NameLoad NameLoad NameLoad
N/A N/A 
=======================================================================================
Topic extraction with Non-negative Matrix Factorization and Latent Dirichlet Allocation
=======================================================================================

This is an example of applying Non-negative Matrix Factorization
and Latent Dirichlet Allocation on a corpus of documents and
extract additive models of the topic structure of the corpus.
The output is a list of topics, each represented as a list of terms
(weights are not shown).

The default parameters (n_samples / n_features / n_topics) should make
the example runnable in a couple of tens of seconds. You can try to
increase the dimensions of the problem, but be aware that the time
complexity is polynomial in NMF. In LDA, the time complexity is
proportional to (n_samples * iterations).
 __future__ print_function time time sklearn.feature_extraction.text TfidfVectorizer CountVectorizer sklearn.decomposition NMF LatentDirichletAllocation sklearn.datasets fetch_20newsgroups N/A n_samples 2000 N/A n_features 1000 N/A n_topics 10 N/A n_top_words 20 print_top_words N/A N/A model feature_names n_top_words N/A N/A N/A N/A topic_idx topic N/A enumerate N/A model components_ N/A N/A N/A print N/A Topic #%d: topic_idx N/A N/A print N/A N/A join N/A N/A feature_names N/A i N/A i N/A N/A N/A topic argsort N/A N/A N/A n_top_words 1 -1 N/A N/A print N/A N/A N/A print Loading dataset... N/A t0 N/A time N/A dataset N/A fetch_20newsgroups shuffle True random_state 1 remove N/A headers footers quotes N/A data_samples N/A N/A dataset data N/A n_samples N/A N/A print N/A done in %0.3fs. N/A N/A time t0 N/A N/A print Extracting tf-idf features for NMF... N/A tfidf_vectorizer N/A TfidfVectorizer max_df 0.95 min_df 2 max_features n_features stop_words english N/A t0 N/A time N/A tfidf N/A N/A tfidf_vectorizer fit_transform data_samples N/A N/A print N/A done in %0.3fs. N/A N/A time t0 N/A N/A print Extracting tf features for LDA... N/A tf_vectorizer N/A CountVectorizer max_df 0.95 min_df 2 max_features n_features stop_words english N/A t0 N/A time N/A tf N/A N/A tf_vectorizer fit_transform data_samples N/A N/A print N/A done in %0.3fs. N/A N/A time t0 N/A N/A print N/A Fitting the NMF model with tf-idf features, n_samples=%d and n_features=%d... N/A n_samples n_features N/A t0 N/A time N/A nmf N/A N/A N/A NMF n_components n_topics random_state 1 alpha 0.1 l1_ratio 0.5 fit tfidf N/A N/A print N/A done in %0.3fs. N/A N/A time t0 N/A N/A print 
Topics in NMF model: N/A tfidf_feature_names N/A N/A tfidf_vectorizer get_feature_names N/A N/A print_top_words nmf tfidf_feature_names n_top_words N/A N/A print N/A Fitting LDA models with tf features, n_samples=%d and n_features=%d... N/A n_samples n_features N/A lda N/A LatentDirichletAllocation n_topics n_topics max_iter 5 learning_method online learning_offset 50.0 random_state 0 N/A t0 N/A time N/A N/A N/A lda fit tf N/A N/A print N/A done in %0.3fs. N/A N/A time t0 N/A N/A print 
Topics in LDA model: N/A tf_feature_names N/A N/A tf_vectorizer get_feature_names N/A N/A print_top_words lda tf_feature_names n_top_words