【发布时间】:2016-09-21 04:44:15
【问题描述】:
根据我在此处发布的有关查询的搜索,我有许多链接提出了解决方案,但没有具体说明如何完成。例如,我探索了以下链接:
等等。
因此,我在这里提出我对如何使用带有 tf-idf 的朴素贝叶斯公式的理解,具体如下:
朴素贝叶斯公式:
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))
tf-idf 权重可以在上面的公式中使用为:
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.
这个问题已经在堆栈溢出上多次发布,但到目前为止还没有任何实质性的答案。我想知道我思考问题的方式是否正确,即我上面展示的实现。我需要知道这一点,因为我自己实现了朴素贝叶斯,而不需要任何 Python 库的帮助,该库带有朴素贝叶斯和 tf-idf 的内置函数。我真正想要的是提高使用朴素贝叶斯训练分类器的模型的准确性(目前为 30%)。因此,如果有更好的方法来实现良好的准确性,欢迎提出建议。
请给我建议。我是这个领域的新手。
【问题讨论】:
标签: python-2.7 tf-idf naivebayes