public class ConfusionMatrix extends java.lang.Object implements Measurable, java.io.Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
ConfusionMatrix.Element
Contains all types of elements of a
ConfusionMatrix. |
| Constructor and Description |
|---|
ConfusionMatrix()
Creates an empty confusion matrix, where all elements are set to zero.
|
ConfusionMatrix(@NotNull ConfusionMatrix confusionMatrix)
Creates a new confusion matrix by copying an existing one.
|
ConfusionMatrix(double truePositives,
double falsePositives,
double trueNegatives,
double falseNegatives)
Creates a new confusion matrix, where the individual elements are set to certain values.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(@NotNull ConfusionMatrix confusionMatrix)
Adds the elements of another confusion matrix to this confusion matrix.
|
void |
add(double truePositives,
double falsePositives,
double trueNegatives,
double falseNegatives)
Adds specific values to the elements of the confusion matrix.
|
double |
addElement(@NotNull ConfusionMatrix.Element element)
Adds a new
ConfusionMatrix.Element with weight 1 to the confusion matrix. |
double |
addElement(@NotNull ConfusionMatrix.Element element,
double weight)
Adds a new
ConfusionMatrix.Element with a certain weight to the confusion matrix. |
double |
addFalseNegative()
Adds a false negative with weight 1.
|
double |
addFalseNegative(double weight)
Adds a false negative with a certain weight.
|
double |
addFalsePositive()
Adds a false positive with weight 1.
|
double |
addFalsePositive(double weight)
Adds a false positive with a certain weight.
|
double |
addTrueNegative()
Adds a true negative with weight 1.
|
double |
addTrueNegative(double weight)
Adds a true negative with a certain weight.
|
double |
addTruePositive()
Adds a true positive with weight 1.
|
double |
addTruePositive(double weight)
Adds a true positive with a certain weight.
|
static @NotNull ConfusionMatrix |
aggregate(@NotNull ConfusionMatrix confusionMatrix1,
@NotNull ConfusionMatrix confusionMatrix2)
Creates and returns a confusion matrix that results from element-wise aggregating two
existing confusion matrices.
|
void |
clear()
Clears the confusion matrix by setting all elements to zero.
|
boolean |
equals(java.lang.Object obj) |
@NotNull ConfusionMatrix |
getConfusionMatrix()
Returns the confusion matrix that can be used to calculate the heuristic value of the
Measurable. |
double |
getCorrectPredictions()
Returns the number of correct predictions.
|
double |
getElement(@NotNull ConfusionMatrix.Element element)
Returns the number of a specific
ConfusionMatrix.Element. |
double |
getFalseNegatives()
Returns the number of false negatives.
|
double |
getFalsePositives()
Returns the number of false positives.
|
double |
getNegativeExamples()
Returns the number of negative examples.
|
double |
getNegativePredictions()
Returns the number of negative predictions.
|
double |
getPositiveExamples()
Returns the number of positive examples.
|
double |
getPositivePredictions()
Returns the number of positive predictions.
|
double |
getTotalPredictions()
Returns the total number of predictions.
|
double |
getTrueNegatives()
Returns the number of true negatives.
|
double |
getTruePositives()
Returns the number of true positives.
|
double |
getWrongPredictions()
Returns the number of wrong predictions.
|
int |
hashCode() |
boolean |
isEmpty()
Returns, whether the confusion matrix is empty, i.e.
|
double |
removeElement(@NotNull ConfusionMatrix.Element element)
Removes a specific
ConfusionMatrix.Element with weight 1 from the confusion matrix. |
double |
removeElement(@NotNull ConfusionMatrix.Element element,
double weight)
Removes a specific
ConfusionMatrix.Element with a certain weight from the confusion matrix. |
double |
removeFalseNegative()
Removes a false negative with weight 1.
|
double |
removeFalseNegative(double weight)
Removes a false negative with a certain weight.
|
double |
removeFalsePositive()
Removes a false positive with weight 1.
|
double |
removeFalsePositive(double weight)
Removes a false positive with a certain weight.
|
double |
removeTrueNegative()
Removes a true negative with weight 1.
|
double |
removeTrueNegative(double weight)
Removes a true negative with a certain weight.
|
double |
removeTruePositive()
Removes a true positive with weight 1.
|
double |
removeTruePositive(double weight)
Removes a true positive with a certain weight.
|
void |
set(@NotNull ConfusionMatrix confusionMatrix)
Sets the elements of the confusion matrix to those of another confusion matrix.
|
void |
set(double truePositives,
double falsePositives,
double trueNegatives,
double falseNegatives)
Sets the elements of the confusion matrix to specific values.
|
void |
setFalseNegatives(double falseNegatives)
Sets the number of false negatives.
|
void |
setFalsePositives(double falsePositives)
Sets the number of false positives.
|
void |
setTrueNegatives(double trueNegatives)
Sets the number of true negatives.
|
void |
setTruePositives(double truePositives)
Sets the number of true positives.
|
java.lang.String |
toString() |
public ConfusionMatrix()
public ConfusionMatrix(@NotNull
@NotNull ConfusionMatrix confusionMatrix)
confusionMatrix - The confusion matrix to be copiedpublic ConfusionMatrix(double truePositives,
double falsePositives,
double trueNegatives,
double falseNegatives)
truePositives - The number of true positivesfalsePositives - The number of false positivestrueNegatives - The number of true negativesfalseNegatives - The number of false negatives@NotNull public static @NotNull ConfusionMatrix aggregate(@NotNull @NotNull ConfusionMatrix confusionMatrix1, @NotNull @NotNull ConfusionMatrix confusionMatrix2)
confusionMatrix1 - The first confusion matrix to be aggregatedconfusionMatrix2 - The second confusion matrix to be aggregatedpublic double getElement(@NotNull
@NotNull ConfusionMatrix.Element element)
ConfusionMatrix.Element.element - The element to be checkedpublic double addElement(@NotNull
@NotNull ConfusionMatrix.Element element)
ConfusionMatrix.Element with weight 1 to the confusion matrix.element - The element to be addedpublic double addElement(@NotNull
@NotNull ConfusionMatrix.Element element,
double weight)
ConfusionMatrix.Element with a certain weight to the confusion matrix.element - The element to be addedweight - The weight of the elementpublic double removeElement(@NotNull
@NotNull ConfusionMatrix.Element element)
ConfusionMatrix.Element with weight 1 from the confusion matrix.element - The element to be removedpublic double removeElement(@NotNull
@NotNull ConfusionMatrix.Element element,
double weight)
ConfusionMatrix.Element with a certain weight from the confusion matrix.element - The element to be removedweight - The weight of the elementpublic void clear()
public boolean isEmpty()
public void set(@NotNull
@NotNull ConfusionMatrix confusionMatrix)
confusionMatrix - The confusion matrix whose elements should be copiedpublic void set(double truePositives,
double falsePositives,
double trueNegatives,
double falseNegatives)
truePositives - The number of true positives to be setfalsePositives - The number of false positives to be settrueNegatives - The number of true negatives to be setfalseNegatives - The number of false negatives to be setpublic void add(@NotNull
@NotNull ConfusionMatrix confusionMatrix)
confusionMatrix - The confusion matrix whose elements should be addedpublic void add(double truePositives,
double falsePositives,
double trueNegatives,
double falseNegatives)
truePositives - The number of true positives to be addedfalsePositives - The number of false positives to be addedtrueNegatives - The number of true negatives to be addedfalseNegatives - The number of false negatives to be addedpublic double getTruePositives()
public void setTruePositives(double truePositives)
truePositives - The number of true positives to be setpublic double addTruePositive()
public double addTruePositive(double weight)
weight - The weight of the true positivepublic double removeTruePositive()
public double removeTruePositive(double weight)
weight - The weight of the true positivepublic double getFalsePositives()
public void setFalsePositives(double falsePositives)
falsePositives - The number of false positives to be setpublic double addFalsePositive()
public double addFalsePositive(double weight)
weight - The weight of the false positivepublic double removeFalsePositive()
public double removeFalsePositive(double weight)
weight - The weight of the false positivepublic double getTrueNegatives()
public void setTrueNegatives(double trueNegatives)
trueNegatives - The number of true negatives to be setpublic double addTrueNegative()
public double addTrueNegative(double weight)
weight - The weight of the true negativepublic double removeTrueNegative()
public double removeTrueNegative(double weight)
weight - The weight of the true negativepublic double getFalseNegatives()
public void setFalseNegatives(double falseNegatives)
falseNegatives - The number of false negatives to be setpublic double addFalseNegative()
public double addFalseNegative(double weight)
weight - The weight of the false negativepublic double removeFalseNegative()
public double removeFalseNegative(double weight)
weight - The weight of the false negativepublic double getTotalPredictions()
public double getCorrectPredictions()
public double getWrongPredictions()
public double getPositivePredictions()
public double getNegativePredictions()
public double getPositiveExamples()
public double getNegativeExamples()
@NotNull public @NotNull ConfusionMatrix getConfusionMatrix()
MeasurableMeasurable.getConfusionMatrix in interface Measurablepublic java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Object