gpt4 book ai didi

python - nltk:使用自定义特征集进行文本分类

转载 作者:太空宇宙 更新时间:2023-11-03 18:47:49 27 4
gpt4 key购买 nike

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

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 过滤器。

引用资料和文档会很有帮助。

最佳答案

你只需要一个简单的字典。看看 NLTK classify interface using trained classifier 中的片段.

这方面的引用文档还是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。

关于python - nltk:使用自定义特征集进行文本分类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19088005/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com