|
||||||||||
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 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.
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 |
---|
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
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
AbstractClassifier
fromXML( StringBuffer )
and should not be made public.
extractFurtherClassifierInfosFromXML
in class AbstractScoreBasedClassifier
xml
- the xml-representation
NonParsableException
protected StringBuffer getFurtherClassifierInfos()
AbstractClassifier
toXML()
and should not be made public.
getFurtherClassifierInfos
in class AbstractScoreBasedClassifier
protected double getScore(Sequence seq, int i, boolean check) throws IllegalArgumentException, NotTrainedException, Exception
AbstractScoreBasedClassifier
getScore
in class AbstractScoreBasedClassifier
seq
- the sequencei
- the index of the classcheck
- the switch to decide whether to check AlphabetContainer and length of the sequence or not
IllegalArgumentException
NotTrainedException
Exception
public CategoricalResult[] getClassifierAnnotation()
AbstractClassifier
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" );
...
getClassifierAnnotation
in class AbstractClassifier
public String getInstanceName()
AbstractClassifier
getInstanceName
in class AbstractClassifier
public NumericalResultSet getNumericalCharacteristics() throws Exception
AbstractClassifier
getCharacteristsics
.
getNumericalCharacteristics
in class AbstractClassifier
Exception
- an Exception
is thrown if some of the characteristics could not be definedprotected String getXMLTag()
AbstractClassifier
fromXML( StringBuffer )
and toXML()
.
getXMLTag
in class AbstractClassifier
public boolean isTrained()
AbstractClassifier
isTrained
in class AbstractClassifier
true
if the classifier is able to classify sequences, otherwise false
public void train(Sample[] s, double[][] weights) throws Exception
AbstractClassifier
Sample
s. That's why the following has
to be fulfilled:
s.length == weights.length
weights[i] == null || s[i].getNumberOfElements() == weights[i].length
.
train( Sample[] )
.
Sample
s are defined over the underlying alphabet and length.
train
in class AbstractClassifier
s
- an array of Sample
sweights
- 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 |