cc.mallet.classify
Class Trial

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<Classification>
              extended by cc.mallet.classify.Trial
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<Classification>, java.util.Collection<Classification>, java.util.List<Classification>, java.util.RandomAccess

public class Trial
extends java.util.ArrayList<Classification>

Stores the results of classifying a collection of Instances, and provides many methods for evaluating the results. If you just need one evaluation result, you may find it easier to one of the corresponding methods in Classifier, which simply call the methods here.

Author:
Andrew McCallum mccallum@cs.umass.edu
See Also:
InstanceList, Classifier, Classification, Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
Trial(Classifier c, InstanceList ilist)
           
 
Method Summary
 boolean add(Classification c)
           
 void add(int index, Classification c)
           
 boolean addAll(java.util.Collection<? extends Classification> collection)
           
 boolean addAll(int index, java.util.Collection<? extends Classification> collection)
           
 double getAccuracy()
          Return the fraction of instances that have the correct label as their best predicted label.
 double getAverageRank()
          Return the average rank of the correct class label as returned by Labeling.getRank(correctLabel) on the predicted Labeling.
 Classifier getClassifier()
           
 double getF1(int index)
          Calculate the F1-measure for a particular target index from an array list of classifications
 double getF1(Labeling label)
           
 double getF1(java.lang.Object labelEntry)
          Calculate the F1-measure of the classifier on an instance list for a particular target entry
 double getPrecision(int index)
          Calculate the precision for a particular target index from an array list of classifications
 double getPrecision(Labeling label)
           
 double getPrecision(java.lang.Object labelEntry)
          Calculate the precision of the classifier on an instance list for a particular target entry
 double getRecall(int labelIndex)
          Calculate the recall for a particular target index from an array list of classifications
 double getRecall(Labeling label)
           
 double getRecall(java.lang.Object labelEntry)
          Calculate the recall of the classifier on an instance list for a particular target entry
 
Methods inherited from class java.util.ArrayList
clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

Trial

public Trial(Classifier c,
             InstanceList ilist)
Method Detail

add

public boolean add(Classification c)
Specified by:
add in interface java.util.Collection<Classification>
Specified by:
add in interface java.util.List<Classification>
Overrides:
add in class java.util.ArrayList<Classification>

add

public void add(int index,
                Classification c)
Specified by:
add in interface java.util.List<Classification>
Overrides:
add in class java.util.ArrayList<Classification>

addAll

public boolean addAll(java.util.Collection<? extends Classification> collection)
Specified by:
addAll in interface java.util.Collection<Classification>
Specified by:
addAll in interface java.util.List<Classification>
Overrides:
addAll in class java.util.ArrayList<Classification>

addAll

public boolean addAll(int index,
                      java.util.Collection<? extends Classification> collection)
Specified by:
addAll in interface java.util.List<Classification>
Overrides:
addAll in class java.util.ArrayList<Classification>

getClassifier

public Classifier getClassifier()

getAccuracy

public double getAccuracy()
Return the fraction of instances that have the correct label as their best predicted label.


getPrecision

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


getPrecision

public double getPrecision(Labeling label)

getPrecision

public double getPrecision(int index)
Calculate the precision for a particular target index from an array list of classifications


getRecall

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


getRecall

public double getRecall(Labeling label)

getRecall

public double getRecall(int labelIndex)
Calculate the recall for a particular target index from an array list of classifications


getF1

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


getF1

public double getF1(Labeling label)

getF1

public double getF1(int index)
Calculate the F1-measure for a particular target index from an array list of classifications


getAverageRank

public double getAverageRank()
Return the average rank of the correct class label as returned by Labeling.getRank(correctLabel) on the predicted Labeling.