de.jstacs.classifier
Class ScoreBasedPerformanceMeasureDefinitions

java.lang.Object
  extended by de.jstacs.classifier.ScoreBasedPerformanceMeasureDefinitions

public class ScoreBasedPerformanceMeasureDefinitions
extends Object

This class contains the methods that are needed to evaluate a score based 2-class-classifier.

Author:
Jens Keilwagen, Jan Grau
See Also:
AbstractScoreBasedClassifier, AbstractClassifier.evaluate(MeasureParameters, boolean, de.jstacs.data.Sample...), AbstractClassifier.evaluateAll(MeasureParameters, boolean, de.jstacs.data.Sample...), MeasureParameters

Nested Class Summary
static class ScoreBasedPerformanceMeasureDefinitions.ThresholdMeasurePair
          This class is used as a container that allows to store a threshold and the result of a measure together.
 
Constructor Summary
ScoreBasedPerformanceMeasureDefinitions()
           
 
Method Summary
static double getAUC_PR(double[] scoresClass0, double[] scoresClass1, AbstractList<double[]> list)
          This method computes the area under the precision recall curve.
static double getAUC_ROC(double[] scoresClass0, double[] scoresClass1, AbstractList<double[]> list)
          This method computes the area under the receiver operator characteristics curve.
static double getClassificationRateFor2Classes(double[] scoresClass0, double[] scoresClass1)
          This method computes the classification rate for two classes.
static ScoreBasedPerformanceMeasureDefinitions.ThresholdMeasurePair getFPRForSensitivity(double[] scoresClass0, double[] scoresClass1, double sensitivity)
          This method computes the false positive rate (FPR) for a given sensitivity.
static ScoreBasedPerformanceMeasureDefinitions.ThresholdMeasurePair getMaxOfCC(double[] scoresClass0, double[] scoresClass1)
          This method computes the maximal correlation coefficient (CC_max).
static double[][] getPartialROC(double[] scoresClass0, double[] scoresClass1, RangeParameter specs)
          This method allows to compute a partial ROC curve.
static ScoreBasedPerformanceMeasureDefinitions.ThresholdMeasurePair getPPVForSensitivity(double[] scoresClass0, double[] scoresClass1, double sensitivity)
          This method computes the positive predictive value (PPV) for a given sensitivity.
static ScoreBasedPerformanceMeasureDefinitions.ThresholdMeasurePair getSensitivityForSpecificity(double[] scoresClass0, double[] scoresClass1, double specificity)
          This method computes the sensitivity for a given specificity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScoreBasedPerformanceMeasureDefinitions

public ScoreBasedPerformanceMeasureDefinitions()
Method Detail

getPartialROC

public static double[][] getPartialROC(double[] scoresClass0,
                                       double[] scoresClass1,
                                       RangeParameter specs)
                                throws ParameterException
This method allows to compute a partial ROC curve.

Parameters:
scoresClass0 - the scores of class 0 (have to be sorted)
scoresClass1 - the scores of class 1 (have to be sorted)
specs - these specificities are used as grid for the partial curve
Returns:
a matrix
  • m[0][i] i-th specificity
  • m[1][i] i-th sensitivity
  • m[2][i] i-th threshold
Throws:
ParameterException - if the method RangeParameter.next() throws one

getAUC_PR

public static double getAUC_PR(double[] scoresClass0,
                               double[] scoresClass1,
                               AbstractList<double[]> list)
This method computes the area under the precision recall curve. It also enables the user to compute the complete curve so that it can be used for plotting. If you like to get the curve, you should use an empty AbstractList for list, otherwise use null.

Parameters:
scoresClass0 - the scores of class 0 (have to be sorted)
scoresClass1 - the scores of class 1 (have to be sorted)
list - null or an empty list
Returns:
the area under the precision recall curve

getAUC_ROC

public static double getAUC_ROC(double[] scoresClass0,
                                double[] scoresClass1,
                                AbstractList<double[]> list)
This method computes the area under the receiver operator characteristics curve. It also enables the user to compute the complete curve so that it can be used for plotting. If you like to get the curve, you should use an empty AbstractList for list, otherwise use null.

Parameters:
scoresClass0 - the scores of class 0 (have to be sorted)
scoresClass1 - the scores of class 1 (have to be sorted)
list - null or an empty list
Returns:
the area under the receiver operator characteristics curve

getFPRForSensitivity

public static ScoreBasedPerformanceMeasureDefinitions.ThresholdMeasurePair getFPRForSensitivity(double[] scoresClass0,
                                                                                                double[] scoresClass1,
                                                                                                double sensitivity)
                                                                                         throws IllegalArgumentException
This method computes the false positive rate (FPR) for a given sensitivity.

Parameters:
scoresClass0 - the scores of class 0 (have to be sorted)
scoresClass1 - the scores of class 1 (have to be sorted)
sensitivity - the fixed sensitivity which is used to measure the FPR
Returns:
the ScoreBasedPerformanceMeasureDefinitions.ThresholdMeasurePair containing the threshold and the FPR
Throws:
IllegalArgumentException - if the sensitivity is not in [0,1]
See Also:
ScoreBasedPerformanceMeasureDefinitions.ThresholdMeasurePair

getPPVForSensitivity

public static ScoreBasedPerformanceMeasureDefinitions.ThresholdMeasurePair getPPVForSensitivity(double[] scoresClass0,
                                                                                                double[] scoresClass1,
                                                                                                double sensitivity)
                                                                                         throws IllegalArgumentException
This method computes the positive predictive value (PPV) for a given sensitivity.

Parameters:
scoresClass0 - the scores of class 0 (have to be sorted)
scoresClass1 - the scores of class 1 (have to be sorted)
sensitivity - the fixed sensitivity which is used to measure the PPV
Returns:
the ScoreBasedPerformanceMeasureDefinitions.ThresholdMeasurePair containing the threshold and the PPV
Throws:
IllegalArgumentException - if the sensitivity is not in [0,1]
See Also:
ScoreBasedPerformanceMeasureDefinitions.ThresholdMeasurePair

getMaxOfCC

public static ScoreBasedPerformanceMeasureDefinitions.ThresholdMeasurePair getMaxOfCC(double[] scoresClass0,
                                                                                      double[] scoresClass1)
                                                                               throws Exception
This method computes the maximal correlation coefficient (CC_max).

Parameters:
scoresClass0 - the scores of class 0 (have to be sorted)
scoresClass1 - the scores of class 1 (have to be sorted)
Returns:
the ScoreBasedPerformanceMeasureDefinitions.ThresholdMeasurePair containing the threshold and the CC_max
Throws:
Exception - if the CC_max can not be computed
See Also:
ScoreBasedPerformanceMeasureDefinitions.ThresholdMeasurePair

getSensitivityForSpecificity

public static ScoreBasedPerformanceMeasureDefinitions.ThresholdMeasurePair getSensitivityForSpecificity(double[] scoresClass0,
                                                                                                        double[] scoresClass1,
                                                                                                        double specificity)
                                                                                                 throws IllegalArgumentException
This method computes the sensitivity for a given specificity.

Parameters:
scoresClass0 - the scores of class 0 (have to be sorted)
scoresClass1 - the scores of class 1 (have to be sorted)
specificity - the specificity that is used to measure the sensitivity
Returns:
the ScoreBasedPerformanceMeasureDefinitions.ThresholdMeasurePair containing the threshold and the sensitivity
Throws:
IllegalArgumentException - if the specificity is not in [0,1]
See Also:
ScoreBasedPerformanceMeasureDefinitions.ThresholdMeasurePair

getClassificationRateFor2Classes

public static double getClassificationRateFor2Classes(double[] scoresClass0,
                                                      double[] scoresClass1)
This method computes the classification rate for two classes.

Parameters:
scoresClass0 - the scores of class 0 (have to be sorted)
scoresClass1 - the scores of class 1 (have to be sorted)
Returns:
the classification rate