public class ClassificationStatistics extends BaseStatistics
This class handles the calculation of statistics for classifiers. It implements the "class cutoff" feature described in BaseClassifier.
Modifier and Type | Field and Description |
---|---|
double |
Accuracy
Accuracy
|
protected double |
class_cutoff
For binary cases: Probability below above which an entry has class = 0
|
java.lang.String[] |
ClassNames
Names of classes (used when printing)
|
int[][] |
ConfusionMatrix
Description of how often instances are assigned to each class
|
int[][] |
ContingencyTable
Contingency table (for binary cases)
|
protected boolean |
discrete_class
Whether class variable should be treated as discrete
|
double |
F1
F1 Score
|
double |
FDR
False Detection Rate
|
int |
FN
Number of False Negatives
|
int |
FP
Number of False Positives
|
double |
FPR
False Positive Rate
|
double |
FractionCorrect
Fraction of entries assigned to correct class
|
double |
Kappa
Fraction correct modified such that 0 is random guessing and 1 is perfect classification
|
double |
MCC
Matthews Correlation Coefficient
|
double |
NPV
Negative Predictive Value
|
int |
NumberCorrect
Number of entries assigned to the correct class
|
double |
PPV
Positive Predictive Value
|
double |
Sensitivity
Sensitivity (aka True Positive Rate
|
double |
Specificity
Specificity (True Negative Rate)
|
int |
TN
Number of True Negatives
|
int |
TP
Number of True Positives
|
Measured, NumberTested, Predicted, ROC, ROC_AUC
Constructor and Description |
---|
ClassificationStatistics() |
Modifier and Type | Method and Description |
---|---|
double[] |
applyClassCutoff(double[] x,
int nclasses)
Takes a continuous class variable and converts it to discrete values that range between
[0,nclass).
|
boolean |
classIsDiscrete() |
java.lang.Object |
clone() |
void |
evaluate(Dataset Data)
Generates statistics about the performance on a model.
|
double |
getClassCutoff() |
java.util.Map<java.lang.String,java.lang.Double> |
getStatistics()
Retrieve list of statistics stored in this class.
|
java.lang.String |
printCommand(java.util.List<java.lang.String> Command)
Handles more complicated printing commands.
|
java.lang.String |
printContingencyTable()
Print out the contingency table
|
void |
setClassContinuous()
Set that the class variable is continuous
|
void |
setClassCutoff(double x)
Set the class cutoff used when calculating statistics.
|
void |
setClassDiscrete()
Set that the class variable is discrete
|
java.lang.String |
toString() |
about, getROCCurve, integrateROCCurve, printDescription, printROCCurve, printUsage, runCommand, saveCommand, savePerformanceData, setOptions
protected double class_cutoff
protected boolean discrete_class
public int NumberCorrect
public double FractionCorrect
public double Kappa
public int[][] ContingencyTable
public int[][] ConfusionMatrix
public int TP
public int FP
public int FN
public int TN
public double Sensitivity
public double FPR
public double Accuracy
public double Specificity
public double PPV
public double NPV
public double FDR
public double MCC
public double F1
public java.lang.String[] ClassNames
public void evaluate(Dataset Data)
BaseStatistics
evaluate
in class BaseStatistics
Data
- Dataset containing both measured and predicted classes.public void setClassCutoff(double x)
x
- Class cutoff (0 <= x <= 1)public double getClassCutoff()
public boolean classIsDiscrete()
public void setClassDiscrete()
public void setClassContinuous()
public double[] applyClassCutoff(double[] x, int nclasses)
nclasses-1
, the following rule
is applied: x[i]-floor(x[i]) > cutoff ? ceil(x[i]) : floor(x[i])
If that value is below 0, it is set to be zero. And, correspondingly, if it is greater than
nclasses-1
it is set to nclasses-1
. The cutoff is
taken from the instance of the ClassificationStatistics.
x
- Array of continuous class variables to be adjustednclasses
- Number of discrete classes knownpublic java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class BaseStatistics
java.lang.CloneNotSupportedException
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.Map<java.lang.String,java.lang.Double> getStatistics()
BaseStatistics
getStatistics
in class BaseStatistics
public java.lang.String printContingencyTable()
public java.lang.String printCommand(java.util.List<java.lang.String> Command) throws java.lang.Exception
Printable
printCommand
in interface Printable
printCommand
in class BaseStatistics
Command
- Command specifying what to printjava.lang.Exception
- If command not understood