public class ConfusionMatrix
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int[][] |
confusion
Holds the confusion matrix.
|
private java.util.ArrayList<ClassLabel> |
labels
Holds the class labels.
|
Constructor and Description |
---|
ConfusionMatrix(java.util.ArrayList<ClassLabel> labels,
int[][] confusion)
Provides a confusion matrix for the given values.
|
Modifier and Type | Method and Description |
---|---|
int |
colSum(int classindex)
The number of instances present in the specified column.
|
int |
falseNegatives(int classindex)
The false negatives for the specified class.
|
double |
falsePositiveRate()
Provides the false positive rate.
|
double |
falsePositiveRate(int classindex)
Provides the false positive rate for the specified class.
|
int |
falsePositives(int classindex)
The false positives for the specified class.
|
double |
positivePredictedValue()
Provides the positive predicted value.
|
double |
positivePredictedValue(int classindex)
Provides the positive predicted value for the specified class.
|
int |
rowSum(int classindex)
The number of instances present in the specified row.
|
java.lang.String |
toString()
Provides a String representation of this confusion matrix.
|
int |
totalInstances()
The total number of instances covered by this confusion matrix.
|
int |
trueNegatives(int classindex)
The number of true negatives of the specified class.
|
double |
truePositiveRate()
Provides the true positive rate.
|
double |
truePositiveRate(int classindex)
Provides the true positive rate for the specified class.
|
int |
truePositives()
The number of correctly classified instances.
|
int |
truePositives(int classindex)
The number of correctly classified instances belonging to the specified
class.
|
int |
value(int trueClassindex,
int predictedClassindex)
The number of instances belonging to class
trueClassindex and
predicted as predictedClassindex . |
private int[][] confusion
confusion[predicted][real]
addresses the number of instances
of class real that have been assigned to the class predicted.private java.util.ArrayList<ClassLabel> labels
public ConfusionMatrix(java.util.ArrayList<ClassLabel> labels, int[][] confusion) throws java.lang.IllegalArgumentException
labels
- the class labels - must conform the confusion matrix in
lengthconfusion
- the confusion matrix. Must be a square matrix. The rows
(first index) give the values which classes are classified as row,
the columns (second index) give the values the class col has been
classified as. Thus, confusion[predicted][real]
addresses the number of instances of class real that have
been assigned to the class predicted.java.lang.IllegalArgumentException
- if the confusion matrix is not square or
not complete or if the length of class labels does not conform the
length of the confusion matrixpublic double truePositiveRate()
TP / (TP+FN)
.public double falsePositiveRate(int classindex)
classindex
- the index of the class to retrieve the false positive
rate forpublic double falsePositiveRate()
FP / (FP+TN)
.public double positivePredictedValue(int classindex)
classindex
- the index of the class to retrieve the positive predicted
value forpublic double positivePredictedValue()
TP / (TP+FP)
.public int truePositives()
public int truePositives(int classindex)
classindex
- the index of the class to retrieve the correctly
classified instances ofpublic double truePositiveRate(int classindex)
classindex
- the index of the class to retrieve the true positive rate
forpublic int trueNegatives(int classindex)
classindex
- the index of the class to retrieve the true negatives forpublic int falsePositives(int classindex)
classindex
- the index of the class to retrieve the false positives
forpublic int falseNegatives(int classindex)
classindex
- the index of the class to retrieve the false negatives
forpublic int totalInstances()
public int rowSum(int classindex)
classindex
.classindex
- the index of the class the resulting number of instances
has been classified aspublic int colSum(int classindex)
classindex
.classindex
- the index of the class theresulting number of instances
belongs topublic int value(int trueClassindex, int predictedClassindex)
trueClassindex
and
predicted as predictedClassindex
.trueClassindex
- the true class indexpredictedClassindex
- the predicted class indextrueClassindex
and predicted as
predictedClassindex
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
Copyright © 2019 ELKI Development Team. License information.