【问题标题】:nltk: Text classification using custom feature setnltk:使用自定义特征集的文本分类
【发布时间】:2013-10-05 22:47:13
【问题描述】:

我有一个如下所示的数据集:

featureDict = {identifier1: [[first 3-gram], [second 3-gram], ... [last 3-gram]],
               ...
               identifierN: [[first 3-gram], [second 3-gram], ... [last 3-gram]]}

另外,我对同一组文档有一个标签字典:

labelDict = {identifier1: label1,
             ...
             identifierN: labelN}

我想找出最合适的 nltk 容器,我可以在其中将这些信息存储在一个地方并无缝应用 nltk 分类器。

此外,在我对这个数据集使用任何分类器之前,我还想在这个特征空间上使用一个 tf-idf 过滤器。

参考资料和文档会很有帮助。

【问题讨论】:

    标签: python text python-3.x classification nltk


    【解决方案1】:

    你只需要一个简单的字典。看看NLTK classify interface using trained classifier中的sn-p。

    这方面的参考文档仍然是 nltk 书:http://nltk.org/book/ch06.html 和 API 规范:http://nltk.org/api/nltk.classify.html

    以下页面可能对您有所帮助:http://snipperize.todayclose.com/snippet/py/Use-NLTK-Toolkit-to-Classify-Documents--5671027/http://streamhacker.com/tag/feature-extraction/http://web2dot5.wordpress.com/2012/03/21/text-classification-in-python/

    另外,请记住,nltk 在它提供的分类器算法方面是有限的。对于更高级的探索,您最好使用 scikit-learn。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-05
      • 2012-07-12
      • 2018-09-11
      • 2016-08-13
      • 2015-12-13
      • 2017-03-16
      • 2019-07-25
      • 2016-06-07
      相关资源
      最近更新 更多