Training a maximum entropy classifier
The third classifier we will cover is the MaxentClassifier
class, also known as a conditional exponential classifier or
logistic regression classifier. The maximum entropy classifier converts labeled feature sets to vectors using encoding. This encoded vector is then used to calculate weights for each feature that can then be combined to determine the most likely label for a feature set. For more details on the math behind this, see https://en.wikipedia.org/wiki/Maximum_entropy_classifier.
Getting ready
The MaxentClassifier
class requires the
NumPy
package. This is because the feature encodings use NumPy
arrays. You can find installation details at the following link:
Get Python 3 Text Processing with NLTK 3 Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.