Class ConfusionMatrixGenerator.ConfusionMatrix
- java.lang.Object
-
- org.apache.lucene.classification.utils.ConfusionMatrixGenerator.ConfusionMatrix
-
- Enclosing class:
- ConfusionMatrixGenerator
public static class ConfusionMatrixGenerator.ConfusionMatrix extends java.lang.Objecta confusion matrix, backed by aMaprepresenting the linearized matrix
-
-
Field Summary
Fields Modifier and Type Field Description private doubleaccuracyprivate doubleavgClassificationTimeprivate java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Long>>linearizedMatrixprivate intnumberOfEvaluatedDocs
-
Constructor Summary
Constructors Modifier Constructor Description privateConfusionMatrix(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Long>> linearizedMatrix, double avgClassificationTime, int numberOfEvaluatedDocs)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublegetAccuracy()Calculate accuracy on this confusion matrix using the formula: accuracy = correctly-classified / (correctly-classified + wrongly-classified)doublegetAvgClassificationTime()get the average classification time in millisecondsdoublegetF1Measure()get the F-1 measure on this confusion matrixdoublegetF1Measure(java.lang.String klass)get the F-1 measure of the given classjava.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Long>>getLinearizedMatrix()get the linearized confusion matrix as aMapintgetNumberOfEvaluatedDocs()get the no.doublegetPrecision()get the macro averaged precision (seegetPrecision(String)) over all the classes.doublegetPrecision(java.lang.String klass)calculate precision on the given classdoublegetRecall()get the macro averaged recall (seegetRecall(String)) over all the classesdoublegetRecall(java.lang.String klass)calculate recall on the given classjava.lang.StringtoString()
-
-
-
Field Detail
-
linearizedMatrix
private final java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Long>> linearizedMatrix
-
avgClassificationTime
private final double avgClassificationTime
-
numberOfEvaluatedDocs
private final int numberOfEvaluatedDocs
-
accuracy
private double accuracy
-
-
Method Detail
-
getLinearizedMatrix
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Long>> getLinearizedMatrix()
get the linearized confusion matrix as aMap- Returns:
- a
Mapwhose keys are the correct classification answers and whose values are the actual answers' counts
-
getPrecision
public double getPrecision(java.lang.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(java.lang.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(java.lang.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 (seegetPrecision(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 (seegetRecall(String)) over all the classes- Returns:
- the recall as computed from the confusion matrix
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.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
-
-