python怎么训练分类器_python – 训练朴素贝叶斯分类器

如果你可以与python,我会说

nltk将是完美的你.

例如:

>>> import nltk

>>> s = "This is some sample data. Nltk will use the words in this string to make ngrams. I hope that this is useful.".split()

>>> model = nltk.NgramModel(2, s)

>>> model._ngrams

set([('to', 'make'), ('sample', 'data.'), ('the', 'words'), ('will', 'use'), ('some', 'sample'), ('', 'This'), ('use', 'the'), ('make', 'ngrams.'), ('ngrams.', 'I'), ('hope', 'that'

), ('is', 'some'), ('is', 'useful.'), ('I', 'hope'), ('this', 'string'), ('Nltk', 'will'), ('words', 'in'), ('this', 'is'), ('data.', 'Nltk'), ('that', 'this'), ('string', 'to'), ('

in', 'this'), ('This', 'is')])

你甚至有一个方法nltk.NaiveBayesClassifier

你可能感兴趣的:(python怎么训练分类器)