de.jstacs.classifiers.performanceMeasures
Class AbstractPerformanceMeasure

java.lang.Object
  extended by de.jstacs.parameters.ParameterSet
      extended by de.jstacs.classifiers.performanceMeasures.AbstractPerformanceMeasure
All Implemented Interfaces:
PerformanceMeasure, GalaxyConvertible, Storable, Cloneable
Direct Known Subclasses:
AbstractTwoClassPerformanceMeasure, ClassificationRate, ConfusionMatrix

public abstract class AbstractPerformanceMeasure
extends ParameterSet
implements PerformanceMeasure

This class is the abstract super class of any performance measure used to evaluate an AbstractClassifier. It is recommended to use the method AbstractClassifier.evaluate(AbstractPerformanceMeasureParameterSet, boolean, de.jstacs.data.DataSet...) for evaluating the performance of any classifier.

Author:
Jan Grau, Jens Keilwagen
See Also:
AbstractClassifier, PerformanceMeasureParameterSet

Nested Class Summary
 
Nested classes/interfaces inherited from class de.jstacs.parameters.ParameterSet
ParameterSet.ParameterList
 
Field Summary
 
Fields inherited from class de.jstacs.parameters.ParameterSet
errorMessage, parameters, parent
 
Constructor Summary
protected AbstractPerformanceMeasure()
          Constructs a new AbstractPerformanceMeasure with empty parameter values.
protected AbstractPerformanceMeasure(StringBuffer xml)
          The standard constructor for the interface Storable.
 
Method Summary
 ResultSet compute(double[][][] classSpecificScores)
          This method allows to compute the performance measure of given class specific scores.
 ResultSet compute(double[] sortedScoresClass0, double[] sortedScoresClass1)
          This method allows to compute the performance measure of given sorted score ratios.
protected static int findSplitIndex(double[] sortedScores, double t)
          Returns the index in sortedScores with value greater or equal to t.
protected static double findThreshold(double[] sortedReferenceScores, double[] sortedMeasureScores, double[] referenceWeights, double percentage, boolean atLeast)
          Determines the threshold for a given percentage on the reference weights using the scores in sortedReferenceScores and sortedMeasureScores.
static SelectionParameter getCollectionOfAllMeasures(int numClasses, boolean numerical)
          This method creates an instance of an SelectionParameter that can be used to create an instance of PerformanceMeasureParameterSet or NumericalPerformanceMeasureParameterSet.
abstract  String getName()
          The method returns the name of the performance measure.
protected static double getWeight(double[] weight, int index)
          Returns the weight at index in weight or 1 if weight is null.
static boolean simpleWeights(double[] weight)
          Returns true if all weights in weight are 1.
 
Methods inherited from class de.jstacs.parameters.ParameterSet
clone, fromGalaxy, fromXML, getAllParameterNames, getComment, getComment, getErrorMessage, getIndex, getName, getName, getNumberOfParameters, getParameterAt, getParameterForName, getParent, hasDefaultOrIsSet, initParameterList, initParameterList, isAtomic, isComparable, parametersLoaded, reset, setParent, toGalaxy, toXML
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.jstacs.classifiers.performanceMeasures.PerformanceMeasure
compute, compute, getAllowedNumberOfClasses
 

Constructor Detail

AbstractPerformanceMeasure

protected AbstractPerformanceMeasure()
Constructs a new AbstractPerformanceMeasure with empty parameter values.


AbstractPerformanceMeasure

protected AbstractPerformanceMeasure(StringBuffer xml)
                              throws NonParsableException
The standard constructor for the interface Storable. Constructs a AbstractPerformanceMeasure out of an XML representation.

Parameters:
xml - the XML representation as StringBuffer
Throws:
NonParsableException - if the AbstractPerformanceMeasure could not be reconstructed out of the StringBuffer xml
Method Detail

getName

public abstract String getName()
Description copied from interface: PerformanceMeasure
The method returns the name of the performance measure.

Specified by:
getName in interface PerformanceMeasure
Returns:
the name of the performance measure

compute

public ResultSet compute(double[] sortedScoresClass0,
                         double[] sortedScoresClass1)
Description copied from interface: PerformanceMeasure
This method allows to compute the performance measure of given sorted score ratios. This method can only be used for binary classifiers.

Specified by:
compute in interface PerformanceMeasure
Parameters:
sortedScoresClass0 - the sorted score ratios of class 0
sortedScoresClass1 - the sorted score ratios of class 1
Returns:
a result set containing the results of the performance measure
See Also:
PerformanceMeasure.compute(double[], double[], double[], double[])

compute

public ResultSet compute(double[][][] classSpecificScores)
Description copied from interface: PerformanceMeasure
This method allows to compute the performance measure of given class specific scores.

Specified by:
compute in interface PerformanceMeasure
Parameters:
classSpecificScores - the scores; first dimension = data sets, second dimension = sequences of the data set, third dimension classes of the classifier
Returns:
a result set containing the results of the performance measure
See Also:
PerformanceMeasure.compute(double[][][], double[][])

getCollectionOfAllMeasures

public static SelectionParameter getCollectionOfAllMeasures(int numClasses,
                                                            boolean numerical)
                                                     throws Exception
This method creates an instance of an SelectionParameter that can be used to create an instance of PerformanceMeasureParameterSet or NumericalPerformanceMeasureParameterSet.

Parameters:
numClasses - the number of classes
numerical - a switch indicating whether all performance measures or only those implementing NumericalPerformanceMeasure shall be contained in the returned SelectionParameter
Returns:
a SelectionParameter that can be used to create an instance of PerformanceMeasureParameterSet or NumericalPerformanceMeasureParameterSet
Throws:
Exception - if something went wrong, e.g. missing empty constructor of any performance measure.
See Also:
AbstractClassifier.getNumberOfClasses()

findThreshold

protected static double findThreshold(double[] sortedReferenceScores,
                                      double[] sortedMeasureScores,
                                      double[] referenceWeights,
                                      double percentage,
                                      boolean atLeast)
Determines the threshold for a given percentage on the reference weights using the scores in sortedReferenceScores and sortedMeasureScores.

Parameters:
sortedReferenceScores - the scores of the reference
sortedMeasureScores - the scores to be thresholded
referenceWeights - the weights on the entries of the reference scores
percentage - the percentage
atLeast - if we do not meet the percentage exactly, shall the actual percentage be at least the given one
Returns:
the threshold

findSplitIndex

protected static int findSplitIndex(double[] sortedScores,
                                    double t)
Returns the index in sortedScores with value greater or equal to t.

Parameters:
sortedScores - the array of sorted values
t - the threshold
Returns:
the index in sortedScores with value greater or equal to t

getWeight

protected static final double getWeight(double[] weight,
                                        int index)
Returns the weight at index in weight or 1 if weight is null.

Parameters:
weight - the weights
index - the index
Returns:
the weight at index or 1

simpleWeights

public static boolean simpleWeights(double[] weight)
Returns true if all weights in weight are 1.

Parameters:
weight - the weights
Returns:
if all weights in weight are 1