class nltk.classify.MaxentClassifier(encoding, weights, logarithmic=True)[source]

A maximum entropy classifier (also known as a “conditional exponential classifier”). This classifier is parameterized by a set of “weights”, which are used to combine the joint-features that are generated from a featureset by an “encoding”. In particular, the encoding maps each (featureset, label) pair to a vector. The probability of each label is then computed using the following equation:

                          dotprod(weights, encode(fs,label))
prob(fs|label) = ---------------------------------------------------
                 sum(dotprod(weights, encode(fs,l)) for l in labels)

Where dotprod is the dot product:

dotprod(a,b) = sum(x*y for (x,y) in zip(a,b))


__init__(encoding, weights[, logarithmic]) Construct a new maxent classifier model.
classify_many(featuresets) Apply self.classify() to each element of featuresets.
explain(featureset[, columns]) Print a table showing the effect of each of the features in the given feature set, and how they combine to determine the probabilities of each label for that featureset.
prob_classify_many(featuresets) Apply self.prob_classify() to each element of featuresets.
set_weights(new_weights) Set the feature weight vector for this classifier.
show_most_informative_features([n, show])
param show:all, neg, or pos (for negative-only or positive-only)
train(train_toks[, algorithm, trace, ...]) Train a new maxent classifier based on the given corpus of training samples.
return:The feature weight vector for this classifier.


ALGORITHMS A list of the algorithm names that are accepted for the train() method’s algorithm parameter.