title: how to use tf-idf with Naive Bayes?
body: <p>As per my search regarding the query, that I am posting here, I have got many links which propose solution but haven't mentioned exactly how this is to be done. I have explored, for example, the following links : </p>
  
  <p><a href="https://www.reddit.com/r/MachineLearning/comments/1inxnq/how_to_factor_in_tfidf_with_naive_bayes/" rel="noreferrer">Link 1</a> </p>
  
  <p><a href="https://stackoverflow.com/questions/6291546/how-to-implement-tf-idf-feature-weighting-with-naive-bayes">Link 2</a></p>
  
  <p><a href="https://stackoverflow.com/questions/3473612/ways-to-improve-the-accuracy-of-a-naive-bayes-classifier?rq=1">Link 3</a></p>
  
  <p><a href="http://onlinepresent.org/proceedings/vol111_2015/50.pdf" rel="noreferrer">Link 4</a></p>
  
  <p>etc. </p>
  
  <p>Therefore, I am presenting my understanding as to how the Naive Bayes formula with tf-idf can be used here and it is as follows: </p>
  
  <p>Naive-Bayes formula : </p>
  
  <pre><code>P(word|class)=(word_count_in_class + 1)/(total_words_in_class+total_unique_words_in_all_classes(basically vocabulary of words in the entire training set))
  </code></pre>
  
  <p>tf-idf weighting can be employed in the above formula as: </p>
  
  <pre><code>word_count_in_class : sum of(tf-idf_weights of the word for all the documents belonging to that class) //basically replacing the counts with the tfidf weights of the same word calculated for every document within that class.
  
  total_words_in_class : sum of (tf-idf weights of all the words belonging to that class) 
  
  total_unique_words_in_all_classes : as is.
  </code></pre>
  
  <p>This question has been posted multiple times on stack overflow but nothing substantial has been answered so far. I want to know that the way I am thinking about the problem is correct or not i.e. implementation that I have shown above. I need to know this as I am implementing the Naive Bayes myself without taking help of any Python library which comes with the built-in functions for both Naive Bayes and tf-idf.  What I actually want is to improve the accuracy(currently 30%) of the model which was using Naive Bayes trained classifier. So, if there are better ways to achieve good accuracy, suggestions are welcome. </p>
  
  <p>Please suggest me. I am new to this domain. </p>