Class ConfusionMatrixGenerator.ConfusionMatrix

java.lang.Object
org.apache.lucene.classification.utils.ConfusionMatrixGenerator.ConfusionMatrix
Enclosing class:
ConfusionMatrixGenerator

public static class ConfusionMatrixGenerator.ConfusionMatrix extends Object
a confusion matrix, backed by a Map representing the linearized matrix
  • Method Details

    • getLinearizedMatrix

      public Map<String,Map<String,Long>> getLinearizedMatrix()
      get the linearized confusion matrix as a Map
      Returns:
      a Map whose keys are the correct classification answers and whose values are the actual answers' counts
    • getPrecision

      public double getPrecision(String klass)
      calculate precision on the given class
      Parameters:
      klass - the class to calculate the precision for
      Returns:
      the precision for the given class
    • getRecall

      public double getRecall(String klass)
      calculate recall on the given class
      Parameters:
      klass - the class to calculate the recall for
      Returns:
      the recall for the given class
    • getF1Measure

      public double getF1Measure(String klass)
      get the F-1 measure of the given class
      Parameters:
      klass - the class to calculate the F-1 measure for
      Returns:
      the F-1 measure for the given class
    • getF1Measure

      public double getF1Measure()
      get the F-1 measure on this confusion matrix
      Returns:
      the F-1 measure
    • getAccuracy

      public double getAccuracy()
      Calculate accuracy on this confusion matrix using the formula: accuracy = correctly-classified / (correctly-classified + wrongly-classified)
      Returns:
      the accuracy
    • getPrecision

      public double getPrecision()
      get the macro averaged precision (see getPrecision(String)) over all the classes.
      Returns:
      the macro averaged precision as computed from the confusion matrix
    • getRecall

      public double getRecall()
      get the macro averaged recall (see getRecall(String)) over all the classes
      Returns:
      the recall as computed from the confusion matrix
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getAvgClassificationTime

      public double getAvgClassificationTime()
      get the average classification time in milliseconds
      Returns:
      the avg classification time
    • getNumberOfEvaluatedDocs

      public int getNumberOfEvaluatedDocs()
      get the no. of documents evaluated while generating this confusion matrix
      Returns:
      the no. of documents evaluated