de.jstacs.classifiers.performanceMeasures
Class AbstractPerformanceMeasureParameterSet<T extends PerformanceMeasure>

java.lang.Object
  extended by de.jstacs.parameters.ParameterSet
      extended by de.jstacs.parameters.ExpandableParameterSet
          extended by de.jstacs.classifiers.performanceMeasures.AbstractPerformanceMeasureParameterSet<T>
Type Parameters:
T - the class of the PerformanceMeasure, typically NumericalPerformanceMeasure or PerformanceMeasure
All Implemented Interfaces:
GalaxyConvertible, Storable, Cloneable
Direct Known Subclasses:
NumericalPerformanceMeasureParameterSet, PerformanceMeasureParameterSet

public class AbstractPerformanceMeasureParameterSet<T extends PerformanceMeasure>
extends ExpandableParameterSet

This class implements a container of PerformanceMeasures that can be used in AbstractClassifier.evaluate(AbstractPerformanceMeasureParameterSet, boolean, de.jstacs.data.DataSet...).

Author:
Jens Keilwagen, Jan Grau

Nested Class Summary
 
Nested classes/interfaces inherited from class de.jstacs.parameters.ParameterSet
ParameterSet.ParameterList
 
Field Summary
 
Fields inherited from class de.jstacs.parameters.ExpandableParameterSet
commentTemplate, nameTemplate, template
 
Fields inherited from class de.jstacs.parameters.ParameterSet
errorMessage, parameters, parent
 
Constructor Summary
protected AbstractPerformanceMeasureParameterSet(int numClasses, boolean numerical, T[] measures)
          Creates a new AbstractPerformanceMeasureParameterSet for the given number of classes and measures using only numerical performance measures or not.
protected AbstractPerformanceMeasureParameterSet(int numClasses, SelectionParameter selection, T... measures)
          This constructor creates an instance with a given template selection that can be used for classifiers handling a given number of classes.
  AbstractPerformanceMeasureParameterSet(StringBuffer xml)
          The standard constructor for the interface Storable.
 
Method Summary
static NumericalPerformanceMeasureParameterSet createFilledParameters()
          Creates a filled NumericalPerformanceMeasureParameterSet that can be used in AbstractClassifier.evaluate(AbstractPerformanceMeasureParameterSet, boolean, de.jstacs.data.DataSet...) or in a ClassifierAssessment.
static AbstractPerformanceMeasureParameterSet createFilledParameters(boolean numerical, double spForSn, double snForFPR, double snForPPV, double beta)
          Creates a filled AbstractPerformanceMeasureParameterSet that can be used in AbstractClassifier.evaluate(AbstractPerformanceMeasureParameterSet, boolean, de.jstacs.data.DataSet...).
 AbstractPerformanceMeasure[] getAllMeasures()
          Returns an array of all contained performance measures.
protected static int getNumberOfClasses(PerformanceMeasure[] measures)
          Returns the number of classes the PerformanceMeasures in measures can be applied to.
 AbstractPerformanceMeasure removeMeasure(int index)
          Removes the measure with index index from the set and returns this measure.
 AbstractPerformanceMeasure[] removeMeasures(Class<? extends AbstractPerformanceMeasure> clazz)
          Removes all measures of a specific class from the set.
 AbstractPerformanceMeasure[] removeMeasures(String name)
          Removes all measures with a specific name.
protected  void setMeasure(T measure)
          Sets the given measure as content of the internally last ParameterSetContainer.
 
Methods inherited from class de.jstacs.parameters.ExpandableParameterSet
addParameterToSet, clone, fromGalaxy, fromXML, parameterRemovable, removeParameterFromSet, replaceContentWith, toGalaxy, toXML
 
Methods inherited from class de.jstacs.parameters.ParameterSet
getAllParameterNames, getComment, getComment, getErrorMessage, getIndex, getName, getName, getNumberOfParameters, getParameterAt, getParameterForName, getParent, hasDefaultOrIsSet, initParameterList, initParameterList, isAtomic, isComparable, parametersLoaded, reset, setParent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPerformanceMeasureParameterSet

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

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

AbstractPerformanceMeasureParameterSet

protected AbstractPerformanceMeasureParameterSet(int numClasses,
                                                 boolean numerical,
                                                 T[] measures)
                                          throws Exception
Creates a new AbstractPerformanceMeasureParameterSet for the given number of classes and measures using only numerical performance measures or not.

Parameters:
numClasses - the number of classes
numerical - the information if all measures shall be NumericalPerformanceMeasures
measures - the measures
Throws:
Exception - if something went wrong

AbstractPerformanceMeasureParameterSet

protected AbstractPerformanceMeasureParameterSet(int numClasses,
                                                 SelectionParameter selection,
                                                 T... measures)
                                          throws Exception
This constructor creates an instance with a given template selection that can be used for classifiers handling a given number of classes. Additional it allows to set some measure initially.

Parameters:
numClasses - the number of classes
selection - the template that can be used to add an select performance measures
measures - the initially set measures
Throws:
Exception - if the measures could not be set (e.g. number of classes differs, ...)
Method Detail

getNumberOfClasses

protected static int getNumberOfClasses(PerformanceMeasure[] measures)
Returns the number of classes the PerformanceMeasures in measures can be applied to.

Parameters:
measures - the measures
Returns:
the number of classes

createFilledParameters

public static NumericalPerformanceMeasureParameterSet createFilledParameters()
                                                                      throws Exception
Creates a filled NumericalPerformanceMeasureParameterSet that can be used in AbstractClassifier.evaluate(AbstractPerformanceMeasureParameterSet, boolean, de.jstacs.data.DataSet...) or in a ClassifierAssessment.

Returns:
a filled NumericalPerformanceMeasureParameterSet
Throws:
Exception - forwarded from createFilledParameters(boolean, double, double, double, double)

createFilledParameters

public static AbstractPerformanceMeasureParameterSet createFilledParameters(boolean numerical,
                                                                            double spForSn,
                                                                            double snForFPR,
                                                                            double snForPPV,
                                                                            double beta)
                                                                     throws Exception
Creates a filled AbstractPerformanceMeasureParameterSet that can be used in AbstractClassifier.evaluate(AbstractPerformanceMeasureParameterSet, boolean, de.jstacs.data.DataSet...). If numerical = false, the parameter set also contains curve measures (e.g. PRCurve, ROCCurve).

Parameters:
numerical - if trueNumericalPerformanceMeasureParameterSet, otherwise AbstractPerformanceMeasureParameterSet
spForSn - the specificity for computing the sensitivity (cf. SensitivityForFixedSpecificity)
snForFPR - the specificity for computing the sensitivity (cf. FalsePositiveRateForFixedSensitivity)
snForPPV - the specificity for computing the sensitivity (cf. PositivePredictiveValueForFixedSensitivity)
beta - the beta of the F-measure (cf. MaximumFMeasure)
Returns:
a filled AbstractPerformanceMeasureParameterSet
Throws:
Exception - if a performance measure could not be created properly (e.g. wrong parameters: sensitivity < 0, ...)

setMeasure

protected void setMeasure(T measure)
                   throws SimpleParameter.IllegalValueException
Sets the given measure as content of the internally last ParameterSetContainer.

Parameters:
measure - the measure to be computed
Throws:
SimpleParameter.IllegalValueException - if the measure could not be set (forwarded from SelectionParameter.setValue(Object))

removeMeasure

public AbstractPerformanceMeasure removeMeasure(int index)
Removes the measure with index index from the set and returns this measure.

Parameters:
index - the index of the measure to be removed
Returns:
the removed measure.

removeMeasures

public AbstractPerformanceMeasure[] removeMeasures(Class<? extends AbstractPerformanceMeasure> clazz)
Removes all measures of a specific class from the set.

Parameters:
clazz - the specific class
Returns:
the removed measures as an array
See Also:
Object.equals(Object)

removeMeasures

public AbstractPerformanceMeasure[] removeMeasures(String name)
Removes all measures with a specific name.

Parameters:
name - the specific name
Returns:
the removed measures as an array
See Also:
AbstractPerformanceMeasure.getName(), String.equals(Object)

getAllMeasures

public AbstractPerformanceMeasure[] getAllMeasures()
Returns an array of all contained performance measures.

Returns:
an array of all contained performance measures.