Package com.bayesserver.analysis
Class ConfusionMatrix
- java.lang.Object
-
- com.bayesserver.analysis.ConfusionMatrix
-
public final class ConfusionMatrix extends Object
Calculates a confusion matrix for a network which is used to predict discrete values (classification).
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ConfusionMatrixcreate(DataReaderCommand readerCommand, String actual, String predicted, String caseWeight)Initializes a new instance of theConfusionMatrixclass.doublegetAccuracy()Gets the overall accuracy of the predictions, which is simply thegetCorrectCount()divided by thegetTotalCount().ConfusionMatrixCellgetCell(Comparable actualValue, Comparable predictedValue)Gets information about a cell in a confusion matrix.doublegetCorrectCount()Gets the total number of correct predictions.List<Comparable>getSortedUniqueValues()Gets a sorted list of unique values which is the union of the different actual and predicted values found.doublegetTotalCount()Gets a count of the number of predictions, whether they were correct or not.
-
-
-
Method Detail
-
create
public static ConfusionMatrix create(DataReaderCommand readerCommand, String actual, String predicted, String caseWeight)
Initializes a new instance of theConfusionMatrixclass.- Parameters:
readerCommand- Returns the data containing the actual values and predicted values.actual- The name of the data column containing the actual value.predicted- The name of the data column containing the predicted value.caseWeight- The case weight, if any. Can be null.
-
getCorrectCount
public double getCorrectCount()
Gets the total number of correct predictions.
-
getTotalCount
public double getTotalCount()
Gets a count of the number of predictions, whether they were correct or not.
-
getAccuracy
public double getAccuracy()
Gets the overall accuracy of the predictions, which is simply thegetCorrectCount()divided by thegetTotalCount().- Returns:
- The accuracy which is a value between 0 and 1.
-
getCell
public ConfusionMatrixCell getCell(Comparable actualValue, Comparable predictedValue)
Gets information about a cell in a confusion matrix.- Parameters:
actualValue- The actual value we want information about.predictedValue- The predicted value we want information about.- Returns:
- A
ConfusionMatrixCellinstance.
-
getSortedUniqueValues
public List<Comparable> getSortedUniqueValues()
Gets a sorted list of unique values which is the union of the different actual and predicted values found.- Returns:
- A sorted list of values.
-
-