All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.classifiers.evaluation.ConfusionMatrix

java.lang.Object
   |
   +----weka.core.Matrix
           |
           +----weka.classifiers.evaluation.ConfusionMatrix

public class ConfusionMatrix
extends Matrix
Cells of this matrix correspond to counts of the number (or weight) of predictions for each actual value / predicted value combination.

Author:
Len Trigg (len@intelligenesis.net)

Constructor Index

 o ConfusionMatrix(String[])
Creates the confusion matrix with the given class names.

Method Index

 o addPrediction(NominalPrediction)
Includes a prediction in the confusion matrix.
 o addPredictions(FastVector)
Includes a whole bunch of predictions in the confusion matrix.
 o className(int)
Gets the name of one of the classes.
 o clone()
Creates and returns a clone of this object.
 o correct()
Gets the number of correct classifications (that is, for which a correct prediction was made).
 o errorRate()
Returns the estimated error rate.
 o getTwoClassStats(int)
Gets the performance with respect to one of the classes as a TwoClassStats object.
 o incorrect()
Gets the number of incorrect classifications (that is, for which an incorrect prediction was made).
 o makeWeighted(CostMatrix)
Makes a copy of this ConfusionMatrix after applying the supplied CostMatrix to the cells.
 o size()
Gets the number of classes.
 o toString()
Calls toString() with a default title.
 o toString(String)
Outputs the performance statistics as a classification confusion matrix.
 o total()
Gets the number of predictions that were made (actually the sum of the weights of predictions where the class value was known).

Constructors

 o ConfusionMatrix
 public ConfusionMatrix(String classNames[])
Creates the confusion matrix with the given class names.

Parameters:
classNames - an array containing the names the classes.

Methods

 o makeWeighted
 public ConfusionMatrix makeWeighted(CostMatrix costs) throws Exception
Makes a copy of this ConfusionMatrix after applying the supplied CostMatrix to the cells. The resulting ConfusionMatrix can be used to get cost-weighted statistics.

Parameters:
costs - the CostMatrix.
Returns:
a ConfusionMatrix that has had costs applied.
Throws: Exception
if the CostMatrix is not of the same size as this ConfusionMatrix.
 o clone
 public Object clone() throws CloneNotSupportedException
Creates and returns a clone of this object.

Returns:
a clone of this instance.
Throws: CloneNotSupportedException
if an error occurs
Overrides:
clone in class Matrix
 o size
 public int size()
Gets the number of classes.

Returns:
the number of classes
 o className
 public String className(int index)
Gets the name of one of the classes.

Parameters:
index - the index of the class.
Returns:
the class name.
 o addPrediction
 public void addPrediction(NominalPrediction pred) throws Exception
Includes a prediction in the confusion matrix.

Parameters:
pred - the NominalPrediction to include
Throws: Exception
if no valid prediction was made (i.e. unclassified).
 o addPredictions
 public void addPredictions(FastVector predictions) throws Exception
Includes a whole bunch of predictions in the confusion matrix.

Parameters:
predictions - a FastVector containing the NominalPredictions to include
Throws: Exception
if no valid prediction was made (i.e. unclassified).
 o getTwoClassStats
 public TwoClassStats getTwoClassStats(int classIndex)
Gets the performance with respect to one of the classes as a TwoClassStats object.

Parameters:
classIndex - the index of the class of interest.
Returns:
the generated TwoClassStats object.
 o correct
 public double correct()
Gets the number of correct classifications (that is, for which a correct prediction was made). (Actually the sum of the weights of these classifications)

Returns:
the number of correct classifications
 o incorrect
 public double incorrect()
Gets the number of incorrect classifications (that is, for which an incorrect prediction was made). (Actually the sum of the weights of these classifications)

Returns:
the number of incorrect classifications
 o total
 public double total()
Gets the number of predictions that were made (actually the sum of the weights of predictions where the class value was known).

Returns:
the number of predictions with known class
 o errorRate
 public double errorRate()
Returns the estimated error rate.

Returns:
the estimated error rate (between 0 and 1).
 o toString
 public String toString()
Calls toString() with a default title.

Returns:
the confusion matrix as a string
Overrides:
toString in class Matrix
 o toString
 public String toString(String title)
Outputs the performance statistics as a classification confusion matrix. For each class value, shows the distribution of predicted class values.

Parameters:
title - the title for the confusion matrix
Returns:
the confusion matrix as a String

All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home