Class ConfusionMatrixGenerator.ConfusionMatrix
- java.lang.Object
-
- org.apache.lucene.classification.utils.ConfusionMatrixGenerator.ConfusionMatrix
-
- Enclosing class:
- ConfusionMatrixGenerator
public static class ConfusionMatrixGenerator.ConfusionMatrix extends java.lang.Object
a confusion matrix, backed by aMap
representing the linearized matrix
-
-
Field Summary
Fields Modifier and Type Field Description private double
accuracy
private double
avgClassificationTime
private java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Long>>
linearizedMatrix
private int
numberOfEvaluatedDocs
-
Constructor Summary
Constructors Modifier Constructor Description private
ConfusionMatrix(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 double
getAccuracy()
Calculate accuracy on this confusion matrix using the formula: accuracy = correctly-classified / (correctly-classified + wrongly-classified)double
getAvgClassificationTime()
get the average classification time in millisecondsdouble
getF1Measure()
get the F-1 measure on this confusion matrixdouble
getF1Measure(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 aMap
int
getNumberOfEvaluatedDocs()
get the no.double
getPrecision()
get the macro averaged precision (seegetPrecision(String)
) over all the classes.double
getPrecision(java.lang.String klass)
calculate precision on the given classdouble
getRecall()
get the macro averaged recall (seegetRecall(String)
) over all the classesdouble
getRecall(java.lang.String klass)
calculate recall on the given classjava.lang.String
toString()
-
-
-
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
Map
whose 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:
toString
in 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
-
-