org.android.activityminer.model.evaluation
Class ConfusionMatrix

Package class diagram package ConfusionMatrix
java.lang.Object
  extended by Jama.Matrix
      extended by org.android.activityminer.model.evaluation.ConfusionMatrix
All Implemented Interfaces:
Serializable, Cloneable

public final class ConfusionMatrix
extends Jama.Matrix

Representation of the confusion matrix for the classes.
It is based on JAMA ( a basic linear algebra package for Java ).

See Also:
Serialized Form

Field Summary
private  android.support.v4.util.LongSparseArray<Integer> mapClassId2Index
          The mapping for indices to the class identifiers
private static long serialVersionUID
          The serial version id.
 
Constructor Summary
ConfusionMatrix(ActivityLabel classLabel)
          Constructor for a confusion matrix of a single class
ConfusionMatrix(long[] classIds)
          Constructor
 
Method Summary
 void add(long predictedClassId, long trueClassId)
          Method to add a prediction result from the evaluation test run to the matrix.
 long getClassIdentifier(int columnIndex)
          Getter for the class identifier for a given column index.
 long[] getClassIdentifierArrayForMatrixIndices()
          Getter for the class identifiers for the matrix indices as array.
 long[] getClassIdentifiers()
          Getter for the class identifiers.
 double getCorrectCount()
          Getter for the count of correct predicted samples.
 double getErrorRate()
          Getter for the error rate.
 double getIncorrectCount()
          Getter for the count of incorrect predicted samples.
 int getIndexForClassId(long classId)
          Getter for the index of a class identifier in the symmetric matrix
 PerClassResult getPerClassResult(long classId)
          Getter for the values of the binary confusion matrix for the given class identifier.
 double getTotalCount()
          Getter for the total count of predicted samples.
 int size()
          Getter for the size.
 
Methods inherited from class Jama.Matrix
arrayLeftDivide, arrayLeftDivideEquals, arrayRightDivide, arrayRightDivideEquals, arrayTimes, arrayTimesEquals, chol, clone, cond, constructWithCopy, copy, det, eig, get, getArray, getArrayCopy, getColumnDimension, getColumnPackedCopy, getMatrix, getMatrix, getMatrix, getMatrix, getRowDimension, getRowPackedCopy, identity, inverse, lu, minus, minusEquals, norm1, norm2, normF, normInf, plus, plusEquals, print, print, print, print, qr, random, rank, read, set, setMatrix, setMatrix, setMatrix, setMatrix, solve, solveTranspose, svd, times, times, timesEquals, trace, transpose, uminus
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
The serial version id.

See Also:
Constant Field Values

mapClassId2Index

private final android.support.v4.util.LongSparseArray<Integer> mapClassId2Index
The mapping for indices to the class identifiers

Constructor Detail

ConfusionMatrix

public ConfusionMatrix(ActivityLabel classLabel)
Constructor for a confusion matrix of a single class

Parameters:
classLabel - the class label

ConfusionMatrix

public ConfusionMatrix(long[] classIds)
Constructor

Parameters:
classIds - the class identifiers
Method Detail

getClassIdentifiers

public final long[] getClassIdentifiers()
Getter for the class identifiers.

Returns:
a collection with the class identifiers

getClassIdentifier

public final long getClassIdentifier(int columnIndex)
Getter for the class identifier for a given column index.

Parameters:
columnIndex - the column index
Returns:
the class identifiers

size

public final int size()
Getter for the size.

Returns:
the size of the confusion matrix, respectively the count of classes

add

public final void add(long predictedClassId,
                      long trueClassId)
Method to add a prediction result from the evaluation test run to the matrix.

Parameters:
predictedClassId - the predicted class identifier
trueClassId - the true class identifier

getIndexForClassId

public final int getIndexForClassId(long classId)
                             throws InvalidParameterException
Getter for the index of a class identifier in the symmetric matrix

Parameters:
classId - the class identifier
Returns:
the index
Throws:
InvalidParameterException - if class label is unknown

getTotalCount

public final double getTotalCount()
Getter for the total count of predicted samples.

Returns:
the total count of predicted samples

getCorrectCount

public final double getCorrectCount()
Getter for the count of correct predicted samples.

Returns:
the count of correct predicted samples

getIncorrectCount

public final double getIncorrectCount()
Getter for the count of incorrect predicted samples.

Returns:
the count of incorrect predicted samples

getErrorRate

public final double getErrorRate()
Getter for the error rate.

Returns:
the error rate

getPerClassResult

public final PerClassResult getPerClassResult(long classId)
Getter for the values of the binary confusion matrix for the given class identifier.

Parameters:
classId - the class identifier
Returns:
the true positive count for the given class

getClassIdentifierArrayForMatrixIndices

public long[] getClassIdentifierArrayForMatrixIndices()
Getter for the class identifiers for the matrix indices as array.

Returns:
the class identifiers for the matrix indices as array