public final class ConfusionMetrics extends Object
ConfusionMatrix
.Modifier and Type | Method and Description |
---|---|
static <T extends Classifiable<T>> |
accuracy(EvaluationMetric.Average average,
ConfusionMatrix<T> cm)
Calculates the accuracy using the specified average type and confusion matrix.
|
static <T extends Classifiable<T>> |
accuracy(MetricTarget<T> target,
ConfusionMatrix<T> cm)
Calculates the accuracy given this confusion matrix.
|
static <T extends Classifiable<T>> |
accuracy(T label,
ConfusionMatrix<T> cm)
Calculates a per label accuracy given this confusion matrix.
|
static <T extends Classifiable<T>> |
balancedErrorRate(ConfusionMatrix<T> cm)
Calculates the balanced error rate, i.e., the mean of the recalls.
|
static double |
f1(double tp,
double fp,
double tn,
double fn)
Computes the F_1 score.
|
static <T extends Classifiable<T>> |
f1(MetricTarget<T> tgt,
ConfusionMatrix<T> cm)
Computes the F_1 score.
|
static <T extends Classifiable<T>> |
fn(MetricTarget<T> tgt,
ConfusionMatrix<T> cm)
Returns the number of false negatives, possibly averaged depending on the metric target.
|
static <T extends Classifiable<T>> |
fp(MetricTarget<T> tgt,
ConfusionMatrix<T> cm)
Returns the number of false positives, possibly averaged depending on the metric target.
|
static double |
fscore(double beta,
double tp,
double fp,
double tn,
double fn)
Computes the Fscore.
|
static <T extends Classifiable<T>> |
fscore(MetricTarget<T> tgt,
ConfusionMatrix<T> cm,
double beta)
Computes the Fscore.
|
static double |
precision(double tp,
double fp,
double tn,
double fn)
Calculates the precision based upon the supplied statistics.
|
static <T extends Classifiable<T>> |
precision(MetricTarget<T> tgt,
ConfusionMatrix<T> cm)
Calculates the precision for this metric target.
|
static double |
recall(double tp,
double fp,
double tn,
double fn)
Calculates the recall based upon the supplied statistics.
|
static <T extends Classifiable<T>> |
recall(MetricTarget<T> tgt,
ConfusionMatrix<T> cm)
Calculates the recall for this metric target.
|
static <T extends Classifiable<T>> |
tn(MetricTarget<T> tgt,
ConfusionMatrix<T> cm)
Returns the number of true negatives, possibly averaged depending on the metric target.
|
static <T extends Classifiable<T>> |
tp(MetricTarget<T> tgt,
ConfusionMatrix<T> cm)
Returns the number of true positives, possibly averaged depending on the metric target.
|
public static <T extends Classifiable<T>> double accuracy(MetricTarget<T> target, ConfusionMatrix<T> cm)
T
- The type parametertarget
- The metric targetcm
- The confusion matrixpublic static <T extends Classifiable<T>> double accuracy(T label, ConfusionMatrix<T> cm)
T
- The type parameterlabel
- The labelcm
- The confusion matrixpublic static <T extends Classifiable<T>> double accuracy(EvaluationMetric.Average average, ConfusionMatrix<T> cm)
T
- the type parameteraverage
- the averagecm
- The confusion matrixpublic static <T extends Classifiable<T>> double balancedErrorRate(ConfusionMatrix<T> cm)
T
- the type parametercm
- The confusion matrixpublic static <T extends Classifiable<T>> double tp(MetricTarget<T> tgt, ConfusionMatrix<T> cm)
T
- the type parametertgt
- The metric targetcm
- The confusion matrixpublic static <T extends Classifiable<T>> double fp(MetricTarget<T> tgt, ConfusionMatrix<T> cm)
T
- the type parametertgt
- The metric targetcm
- The confusion matrixpublic static <T extends Classifiable<T>> double tn(MetricTarget<T> tgt, ConfusionMatrix<T> cm)
T
- the type parametertgt
- The metric targetcm
- The confusion matrixpublic static <T extends Classifiable<T>> double fn(MetricTarget<T> tgt, ConfusionMatrix<T> cm)
T
- the type parametertgt
- The metric targetcm
- The confusion matrixpublic static <T extends Classifiable<T>> double precision(MetricTarget<T> tgt, ConfusionMatrix<T> cm)
T
- the type parametertgt
- The metric targetcm
- The confusion matrixpublic static double precision(double tp, double fp, double tn, double fn)
tp
- the true positivesfp
- the false positivestn
- the true negativesfn
- the false negativespublic static <T extends Classifiable<T>> double recall(MetricTarget<T> tgt, ConfusionMatrix<T> cm)
T
- the type parametertgt
- The metric targetcm
- The confusion matrixpublic static double recall(double tp, double fp, double tn, double fn)
tp
- the true positivesfp
- the false positivestn
- the true negativesfn
- the false negativespublic static <T extends Classifiable<T>> double f1(MetricTarget<T> tgt, ConfusionMatrix<T> cm)
T
- the type parametertgt
- the metric target.cm
- the confusion matrix.public static double f1(double tp, double fp, double tn, double fn)
tp
- the true positivesfp
- the false positivestn
- the true negativesfn
- the false negativespublic static double fscore(double beta, double tp, double fp, double tn, double fn)
beta
- the beta.tp
- the true positives.fp
- the false positives.tn
- the true negatives.fn
- the false negatives.public static <T extends Classifiable<T>> double fscore(MetricTarget<T> tgt, ConfusionMatrix<T> cm, double beta)
T
- the type parametertgt
- The metric targetcm
- The confusion matrixbeta
- the betaCopyright © 2015–2021 Oracle and/or its affiliates. All rights reserved.