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 a 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.

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)` The main constructor.
`MappingClassifier(StringBuffer representation)` This is the constructor for `Storable`.

Method Summary
`protected void` | `extractFurtherClassifierInfosFromXML(StringBuffer xml)` Extracts further information of a classifier from an xml-representation.
`CategoricalResult[]` | `getClassifierAnnotation()` Returns an array of Results of dimension `getNumberOfClasses` that contains information 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 `getCharacteristsics`.
`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.
`boolean` | `isTrained()` This method the state of the classifier.
`Sample[]` | `mapSample(Sample[] s)` This method maps the Samples 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, getResults, getScore, getScores, 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

  The main constructor.

  Parameters:
    `classifier` - the internal used classifier
    `mapping` - the mapping from the classes of the internal classifier to the classes of this classifier
  Throws:
    `CloneNotSupportedException`

### MappingClassifier

    public MappingClassifier(StringBuffer representation)
                      throws NonParsableException

  This is the constructor for `Storable`.

  Parameters:
    `representation` - the xml representation
  Throws:
    `NonParsableException` - if the representation could not be parsed.

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 `fromXML( StringBuffer )` and should not be made public.

  Overrides:
    `extractFurtherClassifierInfosFromXML` in class `AbstractScoreBasedClassifier`
  Parameters:
    `xml` - the xml-representation
  Throws:
    `NonParsableException`

### 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 `toXML()` and should not be made public.

  Overrides:
    `getFurtherClassifierInfos` in class `AbstractScoreBasedClassifier`
  Returns:
    further information of a classifier as a StringBuffer

### 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 length of the sequence or not
  Returns:
    the score
  Throws:
    `IllegalArgumentException`
    `NotTrainedException`
    `Exception`

### getClassifierAnnotation

    public CategoricalResult[] getClassifierAnnotation()

  Description copied from class: `AbstractClassifier`
  Returns an array of Results of dimension `getNumberOfClasses` that contains information 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 Results that contains information 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 `getCharacteristsics`.

  Specified by:
    `getNumericalCharacteristics` in class `AbstractClassifier`
  Returns:
    the numerical characteristics
  Throws:
    `Exception` - an `Exception` is thrown 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. This method is used by the methods `fromXML( StringBuffer )` and `toXML()`.

  Specified by:
    `getXMLTag` in class `AbstractClassifier`
  Returns:
    the String that is used as tag for the xml-representation

### isTrained

    public boolean isTrained()

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

  Specified by:
    `isTrained` in class `AbstractClassifier`
  Returns:
    `true` if the classifier is 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's 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 `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 `s`
  Throws:
    `Exception` - an Exception should be thrown if the weights are incorrect or the training did not succeed

### mapSample

    public Sample[] mapSample(Sample[] s)

  This method maps the Samples to the internal classes.

  Parameters:
    `s` - the array of samples corresponding to the classes of the internal classifier
  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