|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.jstacs.classifier.AbstractClassifier
de.jstacs.classifier.AbstractScoreBasedClassifier
de.jstacs.classifier.MappingClassifier
public class MappingClassifier
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.
| 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 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 Results 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 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 gives information about 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 Samples. |
| 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 |
|---|
public MappingClassifier(AbstractScoreBasedClassifier classifier,
int[] mapping)
throws CloneNotSupportedException
classifier - the internal used classifiermapping - the mapping from the classes of the internal classifier to the
classes of this classifier
CloneNotSupportedException - if something went wrong while cloning the classifier
public MappingClassifier(StringBuffer representation)
throws NonParsableException
Storable.
representation - the XML representation
NonParsableException - if the representation could not be parsed.| Method Detail |
|---|
protected void extractFurtherClassifierInfosFromXML(StringBuffer xml)
throws NonParsableException
AbstractClassifierAbstractClassifier.fromXML(StringBuffer) and
should not be made public.
extractFurtherClassifierInfosFromXML in class AbstractScoreBasedClassifierxml - XML representation
NonParsableException - if the information could not be parsed out of the
StringBufferprotected StringBuffer getFurtherClassifierInfos()
AbstractClassifierStringBuffer. This method is used by the method AbstractClassifier.toXML()
and should not be made public.
getFurtherClassifierInfos in class AbstractScoreBasedClassifierStringBuffer
protected double getScore(Sequence seq,
int i,
boolean check)
throws IllegalArgumentException,
NotTrainedException,
Exception
AbstractScoreBasedClassifier
getScore in class AbstractScoreBasedClassifierseq - the sequencei - the index of the classcheck - the switch to decide whether to check
AlphabetContainer and length of the sequence or not
IllegalArgumentException - if something is wrong with seq
NotTrainedException - if the classifier is not trained
Exception - if something went wrongpublic CategoricalResult[] getClassifierAnnotation()
AbstractClassifierResults 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" );
...
getClassifierAnnotation in class AbstractClassifierResults that contains information the
classifierpublic String getInstanceName()
AbstractClassifier
getInstanceName in class AbstractClassifier
public NumericalResultSet getNumericalCharacteristics()
throws Exception
AbstractClassifierAbstractClassifier.getCharacteristics().
getNumericalCharacteristics in class AbstractClassifierException - an Exception is thrown if some of the
characteristics could not be definedprotected String getXMLTag()
AbstractClassifierString that is used as tag for the XML
representation. This method is used by the methods
AbstractClassifier.fromXML(StringBuffer) and AbstractClassifier.toXML().
getXMLTag in class AbstractClassifierString that is used as tag for the XML representationpublic boolean isTrained()
AbstractClassifier
isTrained in class AbstractClassifiertrue if the classifier is able to classify
sequences, otherwise false
public void train(Sample[] s,
double[][] weights)
throws Exception
AbstractClassifierSamples. That is why the following has to be fulfilled:
s.length == weights.length
weights[i] == null || s[i].getNumberOfElements() == weights[i].length.
train( Sample[] ).
Samples are defined over
the underlying alphabet and length.
train in class AbstractClassifiers - an array of Samplesweights - the weights for s
Exception - an Exception should be thrown if the weights are
incorrect or the training did not succeedpublic Sample[] mapSample(Sample[] s)
s - the array of samples corresponding to the classes of the
internal classifier
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||