public final class ClassificationMetrics
extends javax.visrec.ml.eval.EvaluationMetrics
ConfusionMatrix
,
Evaluators
Modifier and Type | Class and Description |
---|---|
static class |
ClassificationMetrics.Stats
Average values of commonly used classification metrics.
|
Constructor and Description |
---|
ClassificationMetrics(ConfusionMatrix confMatrix)
Constructs a new classification metrics from specified confusion matrix.
|
ClassificationMetrics(ConfusionMatrix confMatrix,
String classLabel,
int classIdx)
Constructs a new classification metrics of a single class for multi class classification.
|
ClassificationMetrics(int trueNegative,
int falsePositive,
int falseNegative,
int truePositive)
Constructs a new classification metrics using specified arguments.
|
Modifier and Type | Method and Description |
---|---|
static ClassificationMetrics.Stats |
average(ClassificationMetrics[] results) |
static ClassificationMetrics[] |
createFrom(ConfusionMatrix confusionMatrix)
Creates classification metrics from the given confusion matrix.
|
float |
getAccuracy()
Percent of correct classifications (for both positive and negative classes).
|
double |
getBalancedAccuracy()
Balanced accuracy is a good metric to use when data set is not balanced.
|
int |
getClassIdx() |
String |
getClassLabel()
Returns class label that these metric correspond to (used for multi class classification).
|
ConfusionMatrix |
getConfusionMatrix()
Returns a confusion matrix that is used to generate these metrics.
|
float |
getErrorRate()
A percent of wrong classifications/predictions made.
|
float |
getF1Score()
Calculates and returns F1 score - a balance between recall and precision.
|
float |
getFalseDiscoveryRate()
When its actually no, how often it is classified as yes
|
float |
getFalseNegativeRate()
When its actually yes, how often does it predicts no
|
float |
getFalsePositiveRate()
When it's actually no, how often does it predict yes?
FP/actual no
|
float |
getFScore(int beta)
Balance between precision and recall.
|
double |
getMatthewsCorrelationCoefficient()
Calculates and returns the matthews corellation coefficient.
|
float |
getPrecision()
What percent of those predicted as positive are really positive.
|
float |
getRecall()
Ratio between those classified as positive compared to those that are actually positive.
|
float |
getSpecificity()
Specificity or true negative rate.
|
int |
getTotal()
Returns total number of classifications.
|
float |
negativeFreqency()
How often does negative class actually occur in the sample
|
float |
positiveFreqency()
How often does positive class actually occur in the sample
|
void |
setClassLabel(String classLabel)
Sets class label to which this metrics corresponds too
|
String |
toString() |
public ClassificationMetrics(ConfusionMatrix confMatrix)
cm
- confusion matrix to extract metrics from.public ClassificationMetrics(ConfusionMatrix confMatrix, String classLabel, int classIdx)
confMatrix
- classLabel
- classIdx
- public ClassificationMetrics(int trueNegative, int falsePositive, int falseNegative, int truePositive)
truePositive
- trueNegative
- falsePositive
- falseNegative
- public String getClassLabel()
public void setClassLabel(String classLabel)
classLabel
- public int getClassIdx()
public ConfusionMatrix getConfusionMatrix()
public float getAccuracy()
public float getErrorRate()
public float getPrecision()
public float getRecall()
public float getSpecificity()
public float getF1Score()
public float getFScore(int beta)
beta
- public int getTotal()
public float getFalsePositiveRate()
public float positiveFreqency()
public float negativeFreqency()
public float getFalseNegativeRate()
public float getFalseDiscoveryRate()
public double getMatthewsCorrelationCoefficient()
http://en.wikipedia.org/wiki/Matthews_correlation_coefficient
public double getBalancedAccuracy()
public String toString()
toString
in class javax.visrec.ml.eval.EvaluationMetrics
public static ClassificationMetrics[] createFrom(ConfusionMatrix confusionMatrix)
confusionMatrix
- public static ClassificationMetrics.Stats average(ClassificationMetrics[] results)
results
- list of different metric results computed on different sets of dataCopyright © 2022. All rights reserved.