public class ConfusionMatrix extends Object
Modifier and Type | Field and Description |
---|---|
static String |
FALSE_NEGATIVE
A label for items falsely classified as negative, which are actually positive.
|
static String |
FALSE_POSITIVE
A label for items falsely classified as positive, which are actually negative.
|
static String |
TRUE_NEGATIVE
A label for items classified as negative which are really negative.
|
static String |
TRUE_POSITIVE
A label for items classified as positive which are really positive.
|
Constructor and Description |
---|
ConfusionMatrix(String[] classLabels)
Creates a new confusion matrix for specified class labels
|
Modifier and Type | Method and Description |
---|---|
int |
get(int actualIdx,
int predictedIdx)
Returns a value of confusion matrix at specified position.
|
int |
getClassCount() |
String[] |
getClassLabels() |
int |
getFalseNegative()
How many positive items has been (falsely) classified as negative.
|
int |
getFalseNegative(int clsIdx) |
int |
getFalsePositive()
Returns number of false positive classifications.
|
int |
getFalsePositive(int clsIdx) |
int |
getTotalItems() |
int |
getTrueNegative() |
int |
getTrueNegative(int clsIdx) |
int |
getTruePositive()
Return true positive metric for binary classification.
|
int |
getTruePositive(int clsIdx)
Returns true positive metric for specified class idx for multiclass classification.
|
void |
inc(int actualIdx,
int predictedIdx)
Increments matrix value at specified position.
|
String |
toString() |
public static final String TRUE_POSITIVE
public static final String TRUE_NEGATIVE
public static final String FALSE_POSITIVE
public static final String FALSE_NEGATIVE
public ConfusionMatrix(String[] classLabels)
classLabels
- public final int get(int actualIdx, int predictedIdx)
actualIdx
- target/actual class idx - corresponds to columnpredictedIdx
- predicted class idx - corresponds to rowpublic final void inc(int actualIdx, int predictedIdx)
actualIdx
- class idx of actual class - corresponds to rowpredictedIdx
- class idx of predicted class - corresponds to columnpublic final int getClassCount()
public int getTruePositive()
public int getTruePositive(int clsIdx)
clsIdx
- Index of class for which true positive value is returnedpublic int getTrueNegative()
public int getTrueNegative(int clsIdx)
public int getFalsePositive()
public int getFalsePositive(int clsIdx)
public int getFalseNegative(int clsIdx)
public int getFalseNegative()
public final String[] getClassLabels()
public int getTotalItems()
Copyright © 2022. All rights reserved.