de.jstacs.classifier
Class ConfusionMatrix

java.lang.Object
  extended by de.jstacs.classifier.ConfusionMatrix
All Implemented Interfaces:
Storable

public class ConfusionMatrix
extends Object
implements Storable

This class holds the confusion matrix of a classifier.

Author:
Jens Keilwagen

Constructor Summary
ConfusionMatrix(int classes)
          Creates a new ConfusionMatrix with a given number of classes.
ConfusionMatrix(StringBuffer representation)
          The standard constructor for the interface Storable.
 
Method Summary
 void add(int realClass, int predictedClass)
          This method updates the confusion matrix.
 int[][] getMatrix()
          This method returns the confusion matrix as a two dimensional int-array.
 double getMisclassificationRate()
          This method returns the misclassification rate.
 StringBuffer toXML()
          This method returns an XML representation as StringBuffer of an instance of the implementing class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfusionMatrix

public ConfusionMatrix(int classes)
Creates a new ConfusionMatrix with a given number of classes.

Parameters:
classes - the number of classes

ConfusionMatrix

public ConfusionMatrix(StringBuffer representation)
                throws NonParsableException
The standard constructor for the interface Storable. Creates a new ConfusionMatrix out of its XML representation.

Parameters:
representation - the XML representation as StringBuffer
Throws:
NonParsableException - if the ConfusionMatrix could not be reconstructed out of the XML representation (the StringBuffer representation could not be parsed)
See Also:
Storable
Method Detail

add

public void add(int realClass,
                int predictedClass)
This method updates the confusion matrix.

Parameters:
realClass - the real class index
predictedClass - the predicted class index

getMatrix

public int[][] getMatrix()
This method returns the confusion matrix as a two dimensional int-array.

Returns:
the confusion matrix

getMisclassificationRate

public double getMisclassificationRate()
This method returns the misclassification rate.

Returns:
the misclassifcation rate

toXML

public StringBuffer toXML()
Description copied from interface: Storable
This method returns an XML representation as StringBuffer of an instance of the implementing class.

Specified by:
toXML in interface Storable
Returns:
the XML representation