cc.mallet.classify
Class Classifier

java.lang.Object
  extended by cc.mallet.classify.Classifier
All Implemented Interfaces:
AlphabetCarrying, java.io.Serializable
Direct Known Subclasses:
AdaBoost, AdaBoostM2, AddClassifierTokenPredictions.TokenClassifiers, BaggingClassifier, BalancedWinnow, C45, ClassifierEnsemble, ConfidencePredictingClassifier, DecisionTree, MaxEnt, MCMaxEnt, NaiveBayes, PRAuxClassifier, Winnow

public abstract class Classifier
extends java.lang.Object
implements AlphabetCarrying, java.io.Serializable

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, Serialized Form

Field Summary
protected  Pipe instancePipe
           
 
Constructor Summary
protected Classifier()
          For serialization only.
  Classifier(Pipe instancePipe)
           
 
Method Summary
 boolean alphabetsMatch(AlphabetCarrying object)
           
abstract  Classification classify(Instance instance)
           
 Classification[] classify(Instance[] instances)
           
 java.util.ArrayList<Classification> classify(InstanceList instances)
           
 Classification classify(java.lang.Object obj)
          Pipe the object through this classifier's pipe, then classify the resulting instance.
 double getAccuracy(InstanceList ilist)
           
 Alphabet getAlphabet()
           
 Alphabet[] getAlphabets()
           
 double getAverageRank(InstanceList ilist)
           
 double getF1(InstanceList ilist, int index)
           
 double getF1(InstanceList ilist, Labeling labeling)
           
 double getF1(InstanceList ilist, java.lang.Object labelEntry)
           
 FeatureSelection getFeatureSelection()
           
 Pipe getInstancePipe()
           
 LabelAlphabet getLabelAlphabet()
           
 FeatureSelection[] getPerClassFeatureSelection()
           
 double getPrecision(InstanceList ilist, int index)
           
 double getPrecision(InstanceList ilist, Labeling labeling)
           
 double getPrecision(InstanceList ilist, java.lang.Object labelEntry)
           
 double getRecall(InstanceList ilist, int index)
           
 double getRecall(InstanceList ilist, Labeling labeling)
           
 double getRecall(InstanceList ilist, java.lang.Object labelEntry)
           
 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()
Specified by:
getAlphabet in interface AlphabetCarrying

getLabelAlphabet

public LabelAlphabet getLabelAlphabet()

getAlphabets

public Alphabet[] getAlphabets()
Specified by:
getAlphabets in interface AlphabetCarrying

alphabetsMatch

public boolean alphabetsMatch(AlphabetCarrying object)

classify

public java.util.ArrayList<Classification> classify(InstanceList instances)

classify

public Classification[] classify(Instance[] instances)

classify

public abstract Classification classify(Instance instance)

classify

public Classification classify(java.lang.Object obj)
Pipe the object through this classifier's pipe, then classify the resulting instance.


getFeatureSelection

public FeatureSelection getFeatureSelection()

getPerClassFeatureSelection

public FeatureSelection[] getPerClassFeatureSelection()

getAccuracy

public double getAccuracy(InstanceList ilist)

getPrecision

public double getPrecision(InstanceList ilist,
                           int index)

getPrecision

public double getPrecision(InstanceList ilist,
                           Labeling labeling)

getPrecision

public double getPrecision(InstanceList ilist,
                           java.lang.Object labelEntry)

getRecall

public double getRecall(InstanceList ilist,
                        int index)

getRecall

public double getRecall(InstanceList ilist,
                        Labeling labeling)

getRecall

public double getRecall(InstanceList ilist,
                        java.lang.Object labelEntry)

getF1

public double getF1(InstanceList ilist,
                    int index)

getF1

public double getF1(InstanceList ilist,
                    Labeling labeling)

getF1

public double getF1(InstanceList ilist,
                    java.lang.Object labelEntry)

getAverageRank

public double getAverageRank(InstanceList ilist)

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)