【问题标题】:How do I look inside the NLTK classifier train method如何查看 NLTK 分类器训练方法
【发布时间】:2018-10-31 08:27:33
【问题描述】:

我一直在看 Laurent Luce 的关于情绪分析的博客。不幸的是,我无法关注他的博客,所以我无法直接向他提问。这是博客的链接:http://www.laurentluce.com/posts/twitter-sentiment-analysis-using-python-and-nltk/

几乎一切都运行良好。但是我无法弄清楚如何让这部分工作 - 下面的文本是从链接中粘贴的。我的问题是如何查看分类器训练方法的内部?如果我能做到这一点,它将有助于我的理解。

“让我们看一下NLTK库的源代码中的分类器训练方法。'label_probdist'是每个标签的先验概率,'feature_probdist'是特征/值概率字典。使用这两个概率对象创建分类器。”

def train(labeled_featuresets, estimator=ELEProbDist):
...
# Create the P(label) distribution
label_probdist = estimator(label_freqdist)
...
# Create the P(fval|label, fname) distribution
feature_probdist = {}
...
return NaiveBayesClassifier(label_probdist, feature_probdist)

【问题讨论】:

    标签: nltk


    【解决方案1】:

    NLTK 是开源的。你可以找到源代码here。 Github 具有可靠的搜索功能,因此您应该能够使用它找到所需的任何内容。具体来说,朴素贝叶斯分类器是here 您可以在该文件中看到它的 train 方法。

    【讨论】:

      猜你喜欢
      • 2011-06-21
      • 2013-04-20
      • 2022-10-06
      • 2017-08-30
      • 2013-01-20
      • 2014-07-11
      • 1970-01-01
      • 2018-12-21
      • 2023-03-11
      相关资源
      最近更新 更多