org.apache.mahout.classifier
Class ConfusionMatrix

java.lang.Object
  extended by org.apache.mahout.classifier.ConfusionMatrix

public class ConfusionMatrix
extends Object

The ConfusionMatrix Class stores the result of Classification of a Test Dataset. The fact of whether there is a default is not stored. A row of zeros is the only indicator that there is no default. See http://en.wikipedia.org/wiki/Confusion_matrix for background


Constructor Summary
ConfusionMatrix(Collection<String> labels, String defaultLabel)
           
ConfusionMatrix(Matrix m)
           
 
Method Summary
 void addInstance(String correctLabel, ClassifierResult classifiedResult)
           
 void addInstance(String correctLabel, String classifiedLabel)
           
 double getAccuracy()
           
 double getAccuracy(String label)
           
 int[][] getConfusionMatrix()
           
 int getCorrect(String label)
           
 int getCount(String correctLabel, String classifiedLabel)
           
 String getDefaultLabel()
           
 double getKappa()
          Accuracy v.s.
 Collection<String> getLabels()
           
 Matrix getMatrix()
           
 RunningAverageAndStdDev getNormalizedStats()
          Standard deviation of normalized producer accuracy Not a standard score
 double getReliability()
           
 int getTotal(String label)
           
 void incrementCount(String correctLabel, String classifiedLabel)
           
 void incrementCount(String correctLabel, String classifiedLabel, int count)
           
 ConfusionMatrix merge(ConfusionMatrix b)
           
 void putCount(String correctLabel, String classifiedLabel, int count)
           
 void setMatrix(Matrix m)
           
 String toString()
          This is overloaded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConfusionMatrix

public ConfusionMatrix(Collection<String> labels,
                       String defaultLabel)

ConfusionMatrix

public ConfusionMatrix(Matrix m)
Method Detail

getConfusionMatrix

public int[][] getConfusionMatrix()

getLabels

public Collection<String> getLabels()

getAccuracy

public double getAccuracy(String label)

getAccuracy

public double getAccuracy()

getReliability

public double getReliability()

getKappa

public double getKappa()
Accuracy v.s. randomly classifying all samples. kappa() = (totalAccuracy() - randomAccuracy()) / (1 - randomAccuracy()) Cohen, Jacob. 1960. A coefficient of agreement for nominal scales. Educational And Psychological Measurement 20:37-46. Formula and variable names from: http://www.yale.edu/ceo/OEFS/Accuracy.pdf

Returns:
double

getNormalizedStats

public RunningAverageAndStdDev getNormalizedStats()
Standard deviation of normalized producer accuracy Not a standard score

Returns:
double

getCorrect

public int getCorrect(String label)

getTotal

public int getTotal(String label)

addInstance

public void addInstance(String correctLabel,
                        ClassifierResult classifiedResult)

addInstance

public void addInstance(String correctLabel,
                        String classifiedLabel)

getCount

public int getCount(String correctLabel,
                    String classifiedLabel)

putCount

public void putCount(String correctLabel,
                     String classifiedLabel,
                     int count)

getDefaultLabel

public String getDefaultLabel()

incrementCount

public void incrementCount(String correctLabel,
                           String classifiedLabel,
                           int count)

incrementCount

public void incrementCount(String correctLabel,
                           String classifiedLabel)

merge

public ConfusionMatrix merge(ConfusionMatrix b)

getMatrix

public Matrix getMatrix()

setMatrix

public void setMatrix(Matrix m)

toString

public String toString()
This is overloaded. toString() is not a formatted report you print for a manager :) Assume that if there are no default assignments, the default feature was not used

Overrides:
toString in class Object


Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.