de.jstacs.classifiers.performanceMeasures
Class PerformanceMeasureParameterSet

java.lang.Object
  extended by de.jstacs.parameters.ParameterSet
      extended by de.jstacs.parameters.ExpandableParameterSet
          extended by de.jstacs.classifiers.performanceMeasures.PerformanceMeasureParameterSet
All Implemented Interfaces:
GalaxyConvertible, Storable, Cloneable
Direct Known Subclasses:
NumericalPerformanceMeasureParameterSet

public class PerformanceMeasureParameterSet
extends ExpandableParameterSet

This class implements a container of AbstractPerformanceMeasures that can be used in AbstractClassifier.evaluate(PerformanceMeasureParameterSet, 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
  PerformanceMeasureParameterSet()
          Constructs a new PerformanceMeasureParameterSet that can be used for binary classifiers.
  PerformanceMeasureParameterSet(AbstractPerformanceMeasure... measures)
          Constructs a new PerformanceMeasureParameterSet with the given performance measures.
  PerformanceMeasureParameterSet(int numClasses)
          Constructs a new PerformanceMeasureParameterSet that can be used for classifiers that handle the given number of classes.
protected PerformanceMeasureParameterSet(int numClasses, SelectionParameter selection, AbstractPerformanceMeasure... measures)
          This constructor creates an instance with a given template selection that can be used for classifiers handling a given number of classes.
  PerformanceMeasureParameterSet(StringBuffer xml)
          The standard constructor for the interface Storable.
 
Method Summary
 void addMeasure(AbstractPerformanceMeasure measure)
          Deprecated. 
static NumericalPerformanceMeasureParameterSet createFilledParameters()
          Creates a filled NumericalPerformanceMeasureParameterSet that can be used in AbstractClassifier.evaluate(PerformanceMeasureParameterSet, boolean, de.jstacs.data.DataSet...)
static PerformanceMeasureParameterSet createFilledParameters(boolean numerical, double spForSn, double snForFPR, double snForPPV, double beta)
          Creates a filled PerformanceMeasureParameterSet that can be used in AbstractClassifier.evaluate(PerformanceMeasureParameterSet, boolean, de.jstacs.data.DataSet...).
 AbstractPerformanceMeasure[] getAllMeasures()
          Returns an array of all contained performance measures.
 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(AbstractPerformanceMeasure 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

PerformanceMeasureParameterSet

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

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

PerformanceMeasureParameterSet

public PerformanceMeasureParameterSet()
                               throws Exception
Constructs a new PerformanceMeasureParameterSet that can be used for binary classifiers.

Throws:
Exception - if something went wrong
See Also:
PerformanceMeasureParameterSet(int)

PerformanceMeasureParameterSet

public PerformanceMeasureParameterSet(int numClasses)
                               throws Exception
Constructs a new PerformanceMeasureParameterSet that can be used for classifiers that handle the given number of classes.

Parameters:
numClasses - the number of classes
Throws:
Exception - if something went wrong
See Also:
AbstractClassifier.getNumberOfClasses(), PerformanceMeasureParameterSet(int, AbstractPerformanceMeasure...)

PerformanceMeasureParameterSet

public PerformanceMeasureParameterSet(AbstractPerformanceMeasure... measures)
                               throws Exception
Constructs a new PerformanceMeasureParameterSet with the given performance measures. The number of classes this PerformanceMeasureParameterSet can be used for is determined from the given AbstractPerformanceMeasures.

Parameters:
measures - the AbstractPerformanceMeasure that shall be used
Throws:
Exception - if something went wrong
See Also:
AbstractClassifier.getNumberOfClasses(), PerformanceMeasureParameterSet(int, SelectionParameter, AbstractPerformanceMeasure... ), AbstractPerformanceMeasure.getCollectionOfAllMeasures(int, boolean)

PerformanceMeasureParameterSet

protected PerformanceMeasureParameterSet(int numClasses,
                                         SelectionParameter selection,
                                         AbstractPerformanceMeasure... 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

createFilledParameters

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

Parameters:
numerical - if trueNumericalPerformanceMeasureParameterSet, otherwise PerformanceMeasureParameterSet
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 PerformanceMeasureParameterSet
Throws:
Exception - if a performance measure could not be created properly (e.g. wrong parameters: sensitivity < 0, ...)

addMeasure

@Deprecated
public void addMeasure(AbstractPerformanceMeasure measure)
                throws CloneNotSupportedException,
                       SimpleParameter.IllegalValueException
Deprecated. 

Adds a performance measure to the set, i.e., enlarges the set by one and set the given measure.

Parameters:
measure - the measure to be added
Throws:
CloneNotSupportedException - if the template could not be cloned (forwarded from ExpandableParameterSet.addParameterToSet()
SimpleParameter.IllegalValueException - forwarded from setMeasure(AbstractPerformanceMeasure)

setMeasure

protected void setMeasure(AbstractPerformanceMeasure 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.