title: Topic modelling - Assign a document with top 2 topics as category label - sklearn Latent Dirichlet Allocation
body: <p>I am now going through LDA(Latent Dirichlet Allocation) Topic modelling method to help in extraction of topics from a set of documents. As from what I have understood from the link below, this is an unsupervised learning approach to categorize / label each of the documents with the extracted topics.</p>
  
  <p><a href="http://scikit-learn.org/stable/auto_examples/applications/topics_extraction_with_nmf_lda.html" rel="noreferrer">Topic extraction with Non-negative Matrix Factorization and Latent Dirichlet Allocation</a></p>
  
  <p>In the sample code given in that link, there is a function defined to get the top words associated with each of the topic identified.</p>
  
  <pre><code>sklearn.__version__
  </code></pre>
  
  <blockquote>
    <p>Out[41]: '0.17'</p>
  </blockquote>
  
  <pre><code>from sklearn.decomposition import LatentDirichletAllocation 
  
  
  def print_top_words(model, feature_names, n_top_words):
      for topic_idx, topic in enumerate(model.components_):
          print("Topic #%d:" % topic_idx)
          print(" ".join([feature_names[i]
                          for i in topic.argsort()[:-n_top_words - 1:-1]]))
      print()
  
  print("\nTopics in LDA model:")
  tf_feature_names = tf_vectorizer.get_feature_names()
  print_top_words(lda, tf_feature_names, n_top_words)
  </code></pre>
  
  <p>My Question is this. Is there <strong>any component or matrix</strong> of the built model LDA, from where we can get the <strong>document-topic association</strong> ?</p>
  
  <p>For example, I need to find <strong>top 2 topics associated with each doc as the document label / Category for that Doc</strong>. Is there any component to find distribution of topics in a document, similar to the  <code>model.components_</code> for finding words distribution within a topic. </p>