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:
http://www.scipy.org/Installing_SciPy
Note
The MaxentClassifier
class algorithms can be quite memory hungry, so you may want to quit all your other programs while training a MaxentClassifier
class, just to be safe.
How to do it...
We will use the same train_feats
and test_feats
variables from...