Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.jstacs.classifier
Class MappingClassifier

    java.lang.Object
      de.jstacs.classifier.AbstractClassifier
          de.jstacs.classifier.AbstractScoreBasedClassifier
              de.jstacs.classifier.MappingClassifier

All Implemented Interfaces:
  Storable, Cloneable

    public class MappingClassifier

extends AbstractScoreBasedClassifier

This class allows the user to train the classifier on a given number of classes and to evaluate the classifier on a smaller number of classes by mapping classes together. For instance the user has a classifier for 3 classes, but likes to evaluate whether the classifier is able to discriminate between class 1 and class 2 and 3. This is a good example where to use this class. The user has to create its 3-class-classifier, create an instance of this class using its classifier, map the test samples together ( `mapSample(Sample[])`) and invoke `AbstractClassifier.evaluate(MeasureParameters, boolean, Sample...)` with these mapped `Sample`. Alternatively, the method `AbstractClassifier.evaluate(MeasureParameters, boolean, Sample...)` can be used directly and the `Sample`s will be mapped internally (i.e. inside the evaluate method).

Author:
  Jens Keilwagen

Nested Class Summary

Nested classes/interfaces inherited from class de.jstacs.classifier.AbstractScoreBasedClassifier
`AbstractScoreBasedClassifier.DoubleTableResult`

Constructor Summary
`MappingClassifier(AbstractScoreBasedClassifier classifier, int... mapping)` Creates a new `MappingClassifier` from a given classifier and a class mapping.
`MappingClassifier(StringBuffer representation)` The standard constructor for the interface `Storable`.

Method Summary
`protected void` | `extractFurtherClassifierInfosFromXML(StringBuffer xml)` Extracts further information of a classifier from an XML representation.
`CategoricalResult[]` | `getClassifierAnnotation()` Returns an array of `Result`s of dimension `AbstractClassifier.getNumberOfClasses()` that contains information about the classifier and for each class.
`protected StringBuffer` | `getFurtherClassifierInfos()` This method returns further information of a classifier as a `StringBuffer`.
`String` | `getInstanceName()` Returns a short description of the classifier.
`NumericalResultSet` | `getNumericalCharacteristics()` Returns the subset of numerical values that are also returned by `AbstractClassifier.getCharacteristics()`.
`protected LinkedList<? extends Result>` | `getResults(Sample[] s, MeasureParameters params, boolean exceptionIfNotComputeable, boolean all)` This method computes the results for any evaluation of the classifier.
`protected double` | `getScore(Sequence seq, int i, boolean check)` This method returns the score for a given `Sequence` and a given class.
`protected String` | `getXMLTag()` Returns the `String` that is used as tag for the XML representation of the classifier.
`boolean` | `isTrained()` This method gives information about the state of the classifier.
`Sample[]` | `mapSample(Sample[] s)` This method maps the given `Sample`s to the internal classes.
`void` | `train(Sample[] s, double[][] weights)` This method trains a classifier over an array of weighted `Sample` s.

Methods inherited from class de.jstacs.classifier.AbstractScoreBasedClassifier
`check, check, classify, classify, clone, createDefaultClassWeights, getClassWeight, getClassWeights, getNumberOfClasses, getPValue, getPValue, getScore, getScores, setClassWeights, setClassWeights, setThresholdClassWeights, test`

Methods inherited from class de.jstacs.classifier.AbstractClassifier
`classify, evaluate, evaluateAll, getAlphabetContainer, getCharacteristics, getClassificationRate, getLength, getMeasuresForEvaluate, getMeasuresForEvaluateAll, setNewAlphabetContainerInstance, toXML, train`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MappingClassifier

    public MappingClassifier(AbstractScoreBasedClassifier classifier,
                             int... mapping)
                      throws CloneNotSupportedException

  Creates a new `MappingClassifier` from a given classifier and a class mapping.

  Parameters:
    `classifier` - the internal used classifier
    `mapping` - the mapping from the classes of the internal classifier to the classes of this classifier
  Throws:
    `CloneNotSupportedException` - if something went wrong while cloning the classifier

### MappingClassifier

    public MappingClassifier(StringBuffer representation)
                      throws NonParsableException

  The standard constructor for the interface `Storable`. Creates a new `MappingClassifier` out of its XML representation.

  Parameters:
    `representation` - the XML representation as `StringBuffer`
  Throws:
    `NonParsableException` - if the `MappingClassifier` could not be reconstructed out of the XML representation (the `StringBuffer` `representation` could not be parsed)
  See Also:
    `AbstractScoreBasedClassifier.AbstractScoreBasedClassifier(StringBuffer)`, `Storable`

Method Detail

### extractFurtherClassifierInfosFromXML

    protected void extractFurtherClassifierInfosFromXML(StringBuffer xml)
                                                 throws NonParsableException

  Description copied from class: `AbstractClassifier`
  Extracts further information of a classifier from an XML representation. This method is used by the method `AbstractClassifier.fromXML(StringBuffer)` and should not be made public.

  Overrides:
    `extractFurtherClassifierInfosFromXML` in class `AbstractScoreBasedClassifier`
  Parameters:
    `xml` - the XML representation as `StringBuffer`
  Throws:
    `NonParsableException` - if the information could not be parsed out of the XML representation (the `StringBuffer` could not be parsed)
  See Also:
    `AbstractClassifier.fromXML(StringBuffer)`

### getFurtherClassifierInfos

    protected StringBuffer getFurtherClassifierInfos()

  Description copied from class: `AbstractClassifier`
  This method returns further information of a classifier as a `StringBuffer`. This method is used by the method `AbstractClassifier.toXML()` and should not be made public.

  Overrides:
    `getFurtherClassifierInfos` in class `AbstractScoreBasedClassifier`
  Returns:
    further information of a classifier as a `StringBuffer`
  See Also:
    `AbstractClassifier.toXML()`

### getScore

    protected double getScore(Sequence seq,
                              int i,
                              boolean check)
                       throws IllegalArgumentException,
                              NotTrainedException,
                              Exception

  Description copied from class: `AbstractScoreBasedClassifier`
  This method returns the score for a given `Sequence` and a given class.

  Specified by:
    `getScore` in class `AbstractScoreBasedClassifier`
  Parameters:
    `seq` - the `Sequence`
    `i` - the index of the class
    `check` - the switch to decide whether to check `AlphabetContainer` and the length of the `Sequence` or not
  Returns:
    the score for a given `Sequence` and a given class
  Throws:
    `IllegalArgumentException` - if something is wrong with the `Sequence` `seq`
    `NotTrainedException` - if the classifier is not trained
    `Exception` - if something went wrong

### getClassifierAnnotation

    public CategoricalResult[] getClassifierAnnotation()

  Description copied from class: `AbstractClassifier`
  Returns an array of `Result`s of dimension `AbstractClassifier.getNumberOfClasses()` that contains information about the classifier and for each class.
  `res[0] = new CategoricalResult( "classifier", "the kind of classifier", getInstanceName() );
  res[1] = new CategoricalResult( "class info 0", "some information about the class", "info0" );
  res[2] = new CategoricalResult( "class info 1", "some information about the class", "info1" );
  ...`

  Specified by:
    `getClassifierAnnotation` in class `AbstractClassifier`
  Returns:
    an array of `Result`s that contains information about the classifier

### getInstanceName

    public String getInstanceName()

  Description copied from class: `AbstractClassifier`
  Returns a short description of the classifier.

  Specified by:
    `getInstanceName` in class `AbstractClassifier`
  Returns:
    a short description of the classifier

### getNumericalCharacteristics

    public NumericalResultSet getNumericalCharacteristics()
                                                   throws Exception

  Description copied from class: `AbstractClassifier`
  Returns the subset of numerical values that are also returned by `AbstractClassifier.getCharacteristics()`.

  Specified by:
    `getNumericalCharacteristics` in class `AbstractClassifier`
  Returns:
    the numerical characteristics
  Throws:
    `Exception` - if some of the characteristics could not be defined

### getXMLTag

    protected String getXMLTag()

  Description copied from class: `AbstractClassifier`
  Returns the `String` that is used as tag for the XML representation of the classifier. This method is used by the methods `AbstractClassifier.fromXML(StringBuffer)` and `AbstractClassifier.toXML()`.

  Specified by:
    `getXMLTag` in class `AbstractClassifier`
  Returns:
    the `String` that is used as tag for the XML representation of the classifier

### isTrained

    public boolean isTrained()

  Description copied from class: `AbstractClassifier`
  This method gives information about the state of the classifier.

  Specified by:
    `isTrained` in class `AbstractClassifier`
  Returns:
    `true` if the classifier is trained and therefore able to classify sequences, otherwise `false`

### train

    public void train(Sample[] s,
                      double[][] weights)
               throws Exception

  Description copied from class: `AbstractClassifier`
  This method trains a classifier over an array of weighted `Sample` s. That is why the following has to be fulfilled:
  - `s.length == weights.length`
  - and for all i: `weights[i] == null || s[i].getNumberOfElements() == weights[i].length`.
  This method should work non-incrementally as the method `AbstractClassifier.train(Sample...)`.
  This method should check that the `Sample`s are defined over the underlying alphabet and length.

  Specified by:
    `train` in class `AbstractClassifier`
  Parameters:
    `s` - an array of `Sample`s
    `weights` - the weights for the `Sample`s
  Throws:
    `Exception` - if the weights are incorrect or the training did not succeed
  See Also:
    `AbstractClassifier.train(Sample...)`

### getResults

    protected LinkedList<? extends Result> getResults(Sample[] s,
                                                      MeasureParameters params,
                                                      boolean exceptionIfNotComputeable,
                                                      boolean all)
                                               throws Exception

  Description copied from class: `AbstractClassifier`
  This method computes the results for any evaluation of the classifier.

  Overrides:
    `getResults` in class `AbstractScoreBasedClassifier`
  Parameters:
    `s` - the array of `Sample`s
    `params` - the current parameters
    `exceptionIfNotComputeable` - indicates the method throws an `Exception` if a measure could not be computed
    `all` - indicates the method computes all results or only the numerical results
  Returns:
    a list of results
  Throws:
    `Exception` - if something went wrong
  See Also:
    `AbstractClassifier.evaluate(MeasureParameters, boolean, Sample...)`, `AbstractClassifier.evaluateAll(MeasureParameters, boolean, Sample...)`

### mapSample

    public Sample[] mapSample(Sample[] s)

  This method maps the given `Sample`s to the internal classes.

  Parameters:
    `s` - the array of `Sample`s
  Returns:
    the array of samples corresponding to the classes

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD