Class ConfusionMatrix


  • public final class ConfusionMatrix
    extends Object
    Calculates a confusion matrix for a network which is used to predict discrete values (classification).
    • Method Detail

      • create

        public static ConfusionMatrix create​(DataReaderCommand readerCommand,
                                             String actual,
                                             String predicted,
                                             String caseWeight)
        Initializes a new instance of the ConfusionMatrix class.
        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 the getCorrectCount() divided by the getTotalCount().
        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 ConfusionMatrixCell instance.
      • 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.