Classifiers label tokens with category labels (or class labels). Typically, labels are represented with strings (such as "health" or "sports". In NLTK, classifiers are defined using classes that implement the ClassifyI interface:
|
Currently, NLTK defines four classifier classes:
Classifiers are typically created by training them on a training corpus.
We define a very simple training corpus with 3 binary features: ['a', 'b', 'c'], and are two labels: ['x', 'y']. We us a simple reason so that the correct answers can be calcualted analytically (although we haven't done this yet for all tests.
|
Test the naive bayes classifier:
|
Test the decision tree classifier:
|
Test the maxent classifier training algorithms; they should all generate the same results.
|