public class DefaultBinaryConfusionMatrix extends AbstractBinaryConfusionMatrix
BinaryConfusionMatrix
. It stores the
four entries in the confusion matrix: true positives, false positives,
true negatives, and false negatives.Modifier and Type | Class and Description |
---|---|
static class |
DefaultBinaryConfusionMatrix.ActualPredictedPairSummarizer
A confusion matrix summarizer that summarizes actual-predicted pairs.
|
static class |
DefaultBinaryConfusionMatrix.CombineSummarizer
A confusion matrix summarizer that adds together confusion matrices.
|
static class |
DefaultBinaryConfusionMatrix.PerformanceEvaluator<InputType>
An implementation of the
SupervisedPerformanceEvaluator interface
for creating a DefaultBinaryConfusionMatrix . |
Modifier and Type | Field and Description |
---|---|
protected double |
falseNegativesCount
Number of false negatives.
|
protected double |
falsePositivesCount
Number of false positives.
|
protected double |
trueNegativesCount
Number of true negatives.
|
protected double |
truePositivesCount
Number of true positives.
|
Constructor and Description |
---|
DefaultBinaryConfusionMatrix()
Creates a new, empty
DefaultBinaryConfusionMatrix . |
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.Boolean target,
java.lang.Boolean estimate,
double value)
Adds a given value to the matrix entry for the (actual, predicted)
pair.
|
static <CategoryType> |
binarizeOnTrueCategory(ConfusionMatrix<CategoryType> matrix,
CategoryType trueCategory)
Takes a general confusion matrix and creates a binary form of it using
true category.
|
static <CategoryType> |
binarizeOnTrueSet(ConfusionMatrix<CategoryType> matrix,
java.util.Set<? super CategoryType> trueSet)
Takes a general confusion matrix and creates a binary form of it using
the given set of true categories.
|
void |
clear()
Empties out all the data in this confusion matrix.
|
DefaultBinaryConfusionMatrix |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
static DefaultBinaryConfusionMatrix |
create(java.lang.Iterable<? extends TargetEstimatePair<? extends java.lang.Boolean,? extends java.lang.Boolean>> input)
Creates a new
DefaultBinaryConfusionMatrix from the given
target-estimate pairs. |
static DefaultBinaryConfusionMatrix |
create(java.lang.Iterable<? extends TargetEstimatePair<? extends java.lang.Boolean,? extends java.lang.Boolean>> input,
boolean weightIfAvailable)
Creates a new
DefaultBinaryConfusionMatrix from the given
target-estimate pairs. |
static DefaultBinaryConfusionMatrix |
createFromActualPredictedPairs(java.util.Collection<? extends Pair<? extends java.lang.Boolean,? extends java.lang.Boolean>> pairs)
Creates a new
DefaultConfusionMatrix from the given
actual-predicted pairs. |
double |
getFalseNegativesCount()
Gets the number of false negatives.
|
double |
getFalseNegativesRate()
Gets the rate of true targets incorrectly classified as false.
|
double |
getFalsePositivesCount()
Gets the number of false positives.
|
double |
getFalsePositivesRate()
Gets the rate of false targets incorrectly classified as true.
|
double |
getTrueNegativesCount()
Gets the number of true negatives.
|
double |
getTrueNegativesRate()
Gets the rate of negative targets correctly classified.
|
double |
getTruePositivesCount()
Gets the number of true positives.
|
double |
getTruePositivesRate()
Gets the rate of target trues that were correctly classified as true.
|
void |
setFalseNegativesCount(double falseNegativesCount)
Sets the number of false negatives in the matrix.
|
void |
setFalsePositivesCount(double falsePositivesCount)
Sets the number of false positives in the matrix.
|
void |
setTrueNegativesCount(double trueNegativesCount)
Sets the number of true negatives in the matrix.
|
void |
setTruePositivesCount(double truePositivesCount)
Sets the number of true positives in the matrix.
|
java.lang.String |
toString() |
getActualCategories, getActualCount, getCategories, getCount, getFalseNegativesFraction, getFalsePositivesFraction, getFScore, getFScore, getPrecision, getPredictedCategories, getPredictedCategories, getRecall, getSensitivity, getSpecificity, getTrueNegativesFraction, getTruePositivesFraction
add, addAll, getAccuracy, getAverageCategoryAccuracy, getAverageCategoryErrorRate, getCategoryAccuracy, getCategoryErrorRate, getErrorRate, getPredictedCount, getTotalCorrectCount, getTotalCount, getTotalIncorrectCount, isEmpty
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
add, addAll, getAccuracy, getAverageCategoryAccuracy, getAverageCategoryErrorRate, getCategoryAccuracy, getCategoryErrorRate, getErrorRate, getPredictedCount, getTotalCorrectCount, getTotalCount, getTotalIncorrectCount, isEmpty
protected double trueNegativesCount
protected double falsePositivesCount
protected double falseNegativesCount
protected double truePositivesCount
public DefaultBinaryConfusionMatrix()
DefaultBinaryConfusionMatrix
.public DefaultBinaryConfusionMatrix clone()
AbstractCloneableSerializable
Object
class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone()
to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil
may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone()
as the basis for your implementation.clone
in interface CloneableSerializable
clone
in class AbstractCloneableSerializable
public void add(java.lang.Boolean target, java.lang.Boolean estimate, double value)
ConfusionMatrix
target
- The actual category.estimate
- The predicted category.value
- The value to add.public void clear()
ConfusionMatrix
public double getTruePositivesCount()
BinaryConfusionMatrix
public void setTruePositivesCount(double truePositivesCount)
truePositivesCount
- The number of true positives. Cannot be negative.public double getFalsePositivesCount()
BinaryConfusionMatrix
public void setFalsePositivesCount(double falsePositivesCount)
falsePositivesCount
- The number of false positives. Cannot be negative.public double getTrueNegativesCount()
BinaryConfusionMatrix
public void setTrueNegativesCount(double trueNegativesCount)
trueNegativesCount
- The number of true negatives. Cannot be negative.public double getFalseNegativesCount()
BinaryConfusionMatrix
public void setFalseNegativesCount(double falseNegativesCount)
falseNegativesCount
- The number of false negatives. Cannot be negative.public double getTrueNegativesRate()
public double getTruePositivesRate()
public double getFalsePositivesRate()
public double getFalseNegativesRate()
public java.lang.String toString()
toString
in class java.lang.Object
public static <CategoryType> DefaultBinaryConfusionMatrix binarizeOnTrueCategory(ConfusionMatrix<CategoryType> matrix, CategoryType trueCategory)
CategoryType
- The true category type.matrix
- The general confusion matrix to binarize.trueCategory
- The value of the true category for the binary confusion matrix.public static <CategoryType> DefaultBinaryConfusionMatrix binarizeOnTrueSet(ConfusionMatrix<CategoryType> matrix, java.util.Set<? super CategoryType> trueSet)
CategoryType
- The true category type.matrix
- The general confusion matrix to binarize.trueSet
- The set of categories in the true set for the binary confusion
matrix.public static DefaultBinaryConfusionMatrix createFromActualPredictedPairs(java.util.Collection<? extends Pair<? extends java.lang.Boolean,? extends java.lang.Boolean>> pairs)
DefaultConfusionMatrix
from the given
actual-predicted pairs.pairs
- The actual-category pairs.public static DefaultBinaryConfusionMatrix create(java.lang.Iterable<? extends TargetEstimatePair<? extends java.lang.Boolean,? extends java.lang.Boolean>> input)
DefaultBinaryConfusionMatrix
from the given
target-estimate pairs.input
- The target-estimate pairs.public static DefaultBinaryConfusionMatrix create(java.lang.Iterable<? extends TargetEstimatePair<? extends java.lang.Boolean,? extends java.lang.Boolean>> input, boolean weightIfAvailable)
DefaultBinaryConfusionMatrix
from the given
target-estimate pairs.input
- The target-estimate pairs.weightIfAvailable
- True uses the weight of each item (or 1.0 if there is none); false
means 1.0 is used regardless of weight.