LBJ2.learn
Class Accuracy

java.lang.Object
  extended by LBJ2.learn.Accuracy
All Implemented Interfaces:
TestingMetric

public class Accuracy
extends java.lang.Object
implements TestingMetric

Returns the accuracy of a discrete classifier with respect to the oracle as the fraction of examples for which its prediction was correct.


Field Summary
private  boolean print
          Whether or not to print a table of results to STDOUT when test(Classifier,Classifier,Parser) is called.
 
Constructor Summary
Accuracy()
          Creates an Accuracy testing metric that does not print a table of results.
Accuracy(boolean p)
          Creates an Accuracy testing metric that prints a table of results if requested.
 
Method Summary
 java.lang.String getName()
          Returns the name of the testing metric.
 double test(Classifier classifier, Classifier oracle, Parser parser)
          Evaluates a classifier against an oracle on the data provided by a parser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

print

private boolean print
Whether or not to print a table of results to STDOUT when test(Classifier,Classifier,Parser) is called.

Constructor Detail

Accuracy

public Accuracy()
Creates an Accuracy testing metric that does not print a table of results.


Accuracy

public Accuracy(boolean p)
Creates an Accuracy testing metric that prints a table of results if requested.

Parameters:
p - Whether or not to print a table of results when test(Classifier,Classifier,Parser) is called.
Method Detail

getName

public java.lang.String getName()
Returns the name of the testing metric.

Specified by:
getName in interface TestingMetric

test

public double test(Classifier classifier,
                   Classifier oracle,
                   Parser parser)
Evaluates a classifier against an oracle on the data provided by a parser.

Specified by:
test in interface TestingMetric
Parameters:
classifier - The classifier whose accuracy is being measured.
oracle - A classifier that returns the label of each example.
parser - A parser to supply the example objects.
Returns:
The fraction of examples for which the classifier's prediction was correct.