【问题标题】:Difficult to understand Naive Bayes Predict() method难以理解朴素贝叶斯 Predict() 方法
【发布时间】:2020-05-30 19:24:32
【问题描述】:

以下方法是EMail Spam Detection项目中预测功能的实现。

预测给定行(邮件)的类

def predict(summaries, inputVector):
    probabilities = calculateClassProbabilities(summaries, inputVector)
    bestLabel, bestProb = None, -1
    for classValue, probability in probabilities.items():
        #print(classValue,'->',probability)
        if bestLabel is None or probability > bestProb:
            bestProb = probability
            bestLabel = classValue
    return bestLabel

我无法理解如何使用上述函数将特定数据项归类为垃圾邮件或火腿

【问题讨论】:

    标签: gaussian naivebayes email-spam


    【解决方案1】:

    calculateClassProbabilities 函数正在完成所有实际工作(可能对字典中的每个单词都有一个垃圾邮件或非垃圾邮件分数,并对电子邮件词汇表的分数求和)。该函数返回一个可能的类别列表(“垃圾邮件”、“合法”、“您确实注册但 dpn 并不想阅读的群发电子邮件”)和相关的概率。这里的循环只是找到概率最高的类别并返回它。

    【讨论】:

      猜你喜欢
      • 2018-02-14
      • 2016-08-18
      • 2012-02-21
      • 2011-12-28
      • 2011-04-08
      • 2017-11-14
      • 2013-09-09
      • 2015-01-03
      • 2017-02-09
      相关资源
      最近更新 更多