edu.umass.cs.mallet.base.classify
Class Classifier

java.lang.Object
  extended byedu.umass.cs.mallet.base.classify.Classifier
Direct Known Subclasses:
AdaBoost, AdaBoostM2, AddClassifierTokenPredictions.TokenClassifiers, BaggingClassifier, BalancedWinnow, C45, ConfidencePredictingClassifier, DecisionTree, MaxEnt, MCMaxEnt, NaiveBayes, Winnow

public abstract class Classifier
extends java.lang.Object

Abstract parent of all Classifiers.

All classification techniques in MALLET are implemented as two classes: a trainer and a classifier. The trainer injests the training data and creates a classifier that holds the parameters set during training. The classifier applies those parameters to an Instance to produce a classification of the Instance.

A concrete classifier is required only to be able to classify an instance.

Methods for classifying an InstanceList are here. There are also methods for calculating precison, recall, and f1 from either InstanceLists (which are classified first) or an ArrayList of classifications. Similar functionality is also in Trial

A classifier holds a reference to the pipe that was used to create the Instances being classified. Most classifiers use this to make sure the Alphabets of the instances being classified are the same Alphabet objects used during training.

Alphabets are allowed to between training and classification.

See Also:
ClassifierTrainer, Instance, InstanceList, Classification, Trial

Field Summary
protected  Pipe instancePipe
           
 
Constructor Summary
protected Classifier()
          For serialization only.
  Classifier(Pipe instancePipe)
           
 
Method Summary
abstract  Classification classify(Instance instance)
           
 Classification[] classify(Instance[] instances)
           
 java.util.ArrayList classify(InstanceList instances)
           
 Classification classify(java.lang.Object obj)
           
 double getAccuracy(java.util.ArrayList classifications)
           
 double getAccuracy(InstanceList ilist)
           
 Alphabet getAlphabet()
           
 double getF1(java.util.ArrayList classification, int index)
          Calculate the F1-measure for a particular target index from an array list of classifications
 double getF1(java.util.ArrayList classification, java.lang.Object entry)
          Calculate the F1-measure for a particular target entry from an array list of classifications
 double getF1(InstanceList ilist, int index)
          Calculate the F1-measure of the classifier on an instance list for a particular target index
 double getF1(InstanceList ilist, java.lang.Object entry)
          Calculate the F1-measure of the classifier on an instance list for a particular target entry
 Pipe getInstancePipe()
           
 LabelAlphabet getLabelAlphabet()
           
 double getPrecision(java.util.ArrayList classification, int index)
          Calculate the precision for a particular target index from an array list of classifications
 double getPrecision(java.util.ArrayList classification, java.lang.Object entry)
          Calculate the precision for a particular target entry from an array list of classifications
 double getPrecision(InstanceList ilist, int index)
          Calculate the precision of the classifier on an instances list for a particular target index
 double getPrecision(InstanceList ilist, java.lang.Object entry)
          Calculate the precision of the classifier on an instance list for a particular target entry
 double getRecall(java.util.ArrayList classification, int index)
          Calculate the recall for a particular target index from an array list of classifications
 double getRecall(java.util.ArrayList classification, java.lang.Object entry)
          Calculate the recall for a particular target entry from an array list of classifications
 double getRecall(InstanceList ilist, int index)
          Calculate the recall of the classifier on an instance list for a particular target index
 double getRecall(InstanceList ilist, java.lang.Object entry)
          Calculate the recall of the classifier on an instance list for a particular target entry
 void print()
          Outputs human-readable description of classifier (e.g., list of weights, decision tree) to System.out
 void print(java.io.PrintWriter out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instancePipe

protected Pipe instancePipe
Constructor Detail

Classifier

protected Classifier()
For serialization only.


Classifier

public Classifier(Pipe instancePipe)
Method Detail

getInstancePipe

public Pipe getInstancePipe()

getAlphabet

public Alphabet getAlphabet()

getLabelAlphabet

public LabelAlphabet getLabelAlphabet()

classify

public java.util.ArrayList classify(InstanceList instances)

classify

public Classification[] classify(Instance[] instances)

classify

public abstract Classification classify(Instance instance)

classify

public Classification classify(java.lang.Object obj)

getAccuracy

public double getAccuracy(InstanceList ilist)

getAccuracy

public double getAccuracy(java.util.ArrayList classifications)

getPrecision

public double getPrecision(InstanceList ilist,
                           java.lang.Object entry)
Calculate the precision of the classifier on an instance list for a particular target entry


getPrecision

public double getPrecision(java.util.ArrayList classification,
                           java.lang.Object entry)
Calculate the precision for a particular target entry from an array list of classifications


getPrecision

public double getPrecision(InstanceList ilist,
                           int index)
Calculate the precision of the classifier on an instances list for a particular target index


getPrecision

public double getPrecision(java.util.ArrayList classification,
                           int index)
Calculate the precision for a particular target index from an array list of classifications


getRecall

public double getRecall(InstanceList ilist,
                        java.lang.Object entry)
Calculate the recall of the classifier on an instance list for a particular target entry


getRecall

public double getRecall(InstanceList ilist,
                        int index)
Calculate the recall of the classifier on an instance list for a particular target index


getRecall

public double getRecall(java.util.ArrayList classification,
                        java.lang.Object entry)
Calculate the recall for a particular target entry from an array list of classifications


getRecall

public double getRecall(java.util.ArrayList classification,
                        int index)
Calculate the recall for a particular target index from an array list of classifications


getF1

public double getF1(InstanceList ilist,
                    java.lang.Object entry)
Calculate the F1-measure of the classifier on an instance list for a particular target entry


getF1

public double getF1(InstanceList ilist,
                    int index)
Calculate the F1-measure of the classifier on an instance list for a particular target index


getF1

public double getF1(java.util.ArrayList classification,
                    java.lang.Object entry)
Calculate the F1-measure for a particular target entry from an array list of classifications


getF1

public double getF1(java.util.ArrayList classification,
                    int index)
Calculate the F1-measure for a particular target index from an array list of classifications


print

public void print()
Outputs human-readable description of classifier (e.g., list of weights, decision tree) to System.out


print

public void print(java.io.PrintWriter out)