|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.classifiers.AbstractClassifier
de.jstacs.classifiers.AbstractScoreBasedClassifier
de.jstacs.classifiers.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 (
mapDataSet(DataSet[])
) and invoke
AbstractClassifier.evaluate(PerformanceMeasureParameterSet, boolean, DataSet...)
with these mapped DataSet
. Alternatively, the method
AbstractClassifier.evaluate(PerformanceMeasureParameterSet, boolean, DataSet...)
can
be used directly and the DataSet
s will be mapped internally
(i.e. inside the evaluate method).
Nested Class Summary |
---|
Nested classes/interfaces inherited from class de.jstacs.classifiers.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 boolean |
getResults(LinkedList list,
DataSet[] s,
PerformanceMeasureParameterSet params,
boolean exceptionIfNotComputeable)
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 |
isInitialized()
This method gives information about the state of the classifier. |
DataSet[] |
mapDataSet(DataSet[] s)
This method maps the given DataSet s to the internal classes. |
void |
train(DataSet[] s,
double[][] weights)
This method trains a classifier over an array of weighted DataSet
s. |
Methods inherited from class de.jstacs.classifiers.AbstractScoreBasedClassifier |
---|
check, check, classify, classify, clone, createDefaultClassWeights, getClassWeight, getClassWeights, getMultiClassScores, getNumberOfClasses, getPValue, getPValue, getScore, getScores, setClassWeights, setClassWeights, setThresholdClassWeights |
Methods inherited from class de.jstacs.classifiers.AbstractClassifier |
---|
classify, evaluate, getAlphabetContainer, getCharacteristics, getLength, 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
MappingClassifier
from a given classifier and a
class mapping.
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 classifierpublic MappingClassifier(StringBuffer representation) throws NonParsableException
Storable
.
Creates a new MappingClassifier
out of its XML representation.
representation
- the XML representation as StringBuffer
NonParsableException
- if the MappingClassifier
could not be reconstructed
out of the XML representation (the StringBuffer
representation
could not be parsed)AbstractScoreBasedClassifier.AbstractScoreBasedClassifier(StringBuffer)
,
Storable
Method Detail |
---|
protected void extractFurtherClassifierInfosFromXML(StringBuffer xml) throws NonParsableException
AbstractClassifier
AbstractClassifier.fromXML(StringBuffer)
and
should not be made public.
extractFurtherClassifierInfosFromXML
in class AbstractScoreBasedClassifier
xml
- the XML representation as StringBuffer
NonParsableException
- if the information could not be parsed out of the XML
representation (the StringBuffer
could not be parsed)AbstractClassifier.fromXML(StringBuffer)
protected StringBuffer getFurtherClassifierInfos()
AbstractClassifier
StringBuffer
. This method is used by the method AbstractClassifier.toXML()
and should not be made public.
getFurtherClassifierInfos
in class AbstractScoreBasedClassifier
StringBuffer
AbstractClassifier.toXML()
protected double getScore(Sequence seq, int i, boolean check) throws IllegalArgumentException, NotTrainedException, Exception
AbstractScoreBasedClassifier
Sequence
and a given
class.
getScore
in class AbstractScoreBasedClassifier
seq
- the Sequence
i
- the index of the classcheck
- the switch to decide whether to check
AlphabetContainer
and the length of the
Sequence
or not
Sequence
and a given class
IllegalArgumentException
- if something is wrong with the Sequence
seq
NotTrainedException
- if the classifier is not trained
Exception
- if something went wrongpublic CategoricalResult[] getClassifierAnnotation()
AbstractClassifier
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" );
...
getClassifierAnnotation
in class AbstractClassifier
Result
s that contains information about the
classifierpublic String getInstanceName()
AbstractClassifier
getInstanceName
in class AbstractClassifier
public NumericalResultSet getNumericalCharacteristics() throws Exception
AbstractClassifier
AbstractClassifier.getCharacteristics()
.
getNumericalCharacteristics
in class AbstractClassifier
Exception
- if some of the characteristics could not be definedprotected String getXMLTag()
AbstractClassifier
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()
.
getXMLTag
in class AbstractClassifier
String
that is used as tag for the XML representation
of the classifierpublic boolean isInitialized()
AbstractClassifier
isInitialized
in class AbstractClassifier
true
if the classifier is initialized and therefore able
to classify sequences, otherwise false
public void train(DataSet[] s, double[][] weights) throws Exception
AbstractClassifier
DataSet
s. That is why the following has to be fulfilled:
s.length == weights.length
weights[i] == null || s[i].getNumberOfElements() == weights[i].length
.
AbstractClassifier.train(DataSet...)
.
DataSet
s are defined over the
underlying alphabet and length.
train
in class AbstractClassifier
s
- an array of DataSet
sweights
- the weights for the DataSet
s
Exception
- if the weights are incorrect or the training did not succeedAbstractClassifier.train(DataSet...)
protected boolean getResults(LinkedList list, DataSet[] s, PerformanceMeasureParameterSet params, boolean exceptionIfNotComputeable) throws Exception
AbstractClassifier
getResults
in class AbstractScoreBasedClassifier
list
- a list adding the resultss
- the array of DataSet
sparams
- the current parametersexceptionIfNotComputeable
- indicates the method throws an Exception
if a measure
could not be computed
Exception
- if something went wrongAbstractClassifier.evaluate(PerformanceMeasureParameterSet, boolean, DataSet...)
,
NumericalResult
,
Result
public DataSet[] mapDataSet(DataSet[] s)
DataSet
s to the internal classes.
s
- the array of DataSet
s
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |