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)
          This constructor creates an instance with a given number of classes.
ConfusionMatrix(StringBuffer representation)
          This is the constructor for 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 2D-int-array.
 double getMisclassificationRate()
          This method returns the misclassification rate.
 StringBuffer toXML()
          This method returns an XML-representation 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)
This constructor creates an instance with a given number of classes.

Parameters:
classes - the number of classes

ConfusionMatrix

public ConfusionMatrix(StringBuffer representation)
                throws NonParsableException
This is the constructor for Storable.

Parameters:
representation - the xml representation
Throws:
NonParsableException - if the representation could not be parsed.
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 2D-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 of an instance of the implementing class.

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