【问题标题】:Difference between NLTK and Scikit Naive BayesNLTK 和 Scikit 朴素贝叶斯的区别
【发布时间】:2019-08-04 20:49:11
【问题描述】:

我想知道 NLTK 中朴素贝叶斯的本质是什么吗?是伯努利、多项式、高斯还是任何其他变体?我通读了文档,但似乎太笼统了。

我知道 scikit 有 4 个版本的朴素贝叶斯,其中只有两个适合文本处理。

在进行文本处理时,我发现 NLTK 朴素贝叶斯和 scikit 之间存在显着差异。

【问题讨论】:

    标签: python scikit-learn nltk


    【解决方案1】:

    NLTK 朴素贝叶斯属于多项式(典型的分类),其线索是高斯朴素贝叶斯通常用于连续数据(不是文本分类的典型)。

    NLTK 朴素贝叶斯的官方文档可以在这里找到:https://www.nltk.org/_modules/nltk/classify/naivebayes.html

    关键文本示例-

    A classifier based on the Naive Bayes algorithm.  In order to find the
    probability for a label, this algorithm first uses the Bayes rule to
    express P(label|features) in terms of P(label) and P(features|label):
    
    |                       P(label) * P(features|label)
    |  P(label|features) = ------------------------------
    |                              P(features)
    
    The algorithm then makes the 'naive' assumption that all features are
    independent, given the label:
    
    |                       P(label) * P(f1|label) * ... * P(fn|label)
    |  P(label|features) = --------------------------------------------
    |                                         P(features)
    
    Rather than computing P(features) explicitly, the algorithm just
    calculates the numerator for each label, and normalizes them so they
    sum to one:
    
    |                       P(label) * P(f1|label) * ... * P(fn|label)
    |  P(label|features) = --------------------------------------------
    |                        SUM[l]( P(l) * P(f1|l) * ... * P(fn|l) )
    

    【讨论】:

      猜你喜欢
      • 2016-05-01
      • 2014-01-13
      • 2015-12-20
      • 2016-09-28
      • 2017-04-19
      • 2015-09-16
      • 2018-02-06
      • 2013-03-21
      • 2012-08-31
      相关资源
      最近更新 更多