Class Classifier
- java.lang.Object
-
- 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,MostFrequentClassifier,NaiveBayes,PRAuxClassifier,RandomClassifier,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
TrialA 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
Fields Modifier and Type Field Description protected PipeinstancePipe
-
Constructor Summary
Constructors Modifier Constructor Description protectedClassifier()For serialization only.Classifier(Pipe instancePipe)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanalphabetsMatch(AlphabetCarrying object)abstract Classificationclassify(Instance instance)Classification[]classify(Instance[] instances)java.util.ArrayList<Classification>classify(InstanceList instances)Classificationclassify(java.lang.Object obj)Pipe the object through this classifier's pipe, then classify the resulting instance.doublegetAccuracy(InstanceList ilist)AlphabetgetAlphabet()Alphabet[]getAlphabets()doublegetAverageRank(InstanceList ilist)doublegetF1(InstanceList ilist, int index)doublegetF1(InstanceList ilist, Labeling labeling)doublegetF1(InstanceList ilist, java.lang.Object labelEntry)FeatureSelectiongetFeatureSelection()PipegetInstancePipe()LabelAlphabetgetLabelAlphabet()FeatureSelection[]getPerClassFeatureSelection()doublegetPrecision(InstanceList ilist, int index)doublegetPrecision(InstanceList ilist, Labeling labeling)doublegetPrecision(InstanceList ilist, java.lang.Object labelEntry)doublegetRecall(InstanceList ilist, int index)doublegetRecall(InstanceList ilist, Labeling labeling)doublegetRecall(InstanceList ilist, java.lang.Object labelEntry)voidprint()Outputs human-readable description of classifier (e.g., list of weights, decision tree) to System.outvoidprint(java.io.PrintWriter out)
-
-
-
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:
getAlphabetin interfaceAlphabetCarrying
-
getLabelAlphabet
public LabelAlphabet getLabelAlphabet()
-
getAlphabets
public Alphabet[] getAlphabets()
- Specified by:
getAlphabetsin interfaceAlphabetCarrying
-
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)
-
-