public class MappingClassifier extends AbstractScoreBasedClassifier
mapDataSet(DataSet[])
) and invoke
AbstractClassifier.evaluate(AbstractPerformanceMeasureParameterSet, boolean, DataSet...)
with these mapped DataSet
. Alternatively, the method
AbstractClassifier.evaluate(AbstractPerformanceMeasureParameterSet, boolean, DataSet...)
can
be used directly and the DataSet
s will be mapped internally
(i.e. inside the evaluate method).AbstractScoreBasedClassifier.DoubleTableResult
Constructor and Description |
---|
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 . |
Modifier and Type | Method and Description |
---|---|
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.
res[0] = new CategoricalResult( "classifier", "the kind of classifier", getInstanceName() );
|
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,
double[][] weights,
AbstractPerformanceMeasureParameterSet<? extends PerformanceMeasure> 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. |
double[][] |
mapWeights(double[][] w)
This method maps the given
Sequence weights to the internal classes. |
void |
train(DataSet[] s,
double[][] weights)
This method trains a classifier over an array of weighted
DataSet
s. |
check, check, classify, classify, clone, createDefaultClassWeights, getClassWeight, getClassWeights, getMultiClassScores, getNumberOfClasses, getPValue, getPValue, getScore, getScores, setClassWeights, setClassWeights, setThresholdClassWeights
classify, evaluate, evaluate, getAlphabetContainer, getCharacteristics, getLength, toXML, train
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 classifierCloneNotSupportedException
- 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
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 notSequence
and a given classIllegalArgumentException
- if something is wrong with the Sequence
seq
NotTrainedException
- if the classifier is not trainedException
- 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
sException
- if the weights are incorrect or the training did not succeedAbstractClassifier.train(DataSet...)
protected boolean getResults(LinkedList list, DataSet[] s, double[][] weights, AbstractPerformanceMeasureParameterSet<? extends PerformanceMeasure> params, boolean exceptionIfNotComputeable) throws Exception
AbstractClassifier
getResults
in class AbstractScoreBasedClassifier
list
- a list adding the resultss
- the array of DataSet
sweights
- the weights of the sequences for each data setparams
- the current parametersexceptionIfNotComputeable
- indicates the method throws an Exception
if a measure
could not be computedException
- if something went wrongAbstractClassifier.evaluate(AbstractPerformanceMeasureParameterSet, boolean, DataSet[], double[][])
,
NumericalResult
,
Result
public DataSet[] mapDataSet(DataSet[] s)
DataSet
s to the internal classes.s
- the array of DataSet
spublic double[][] mapWeights(double[][] w)
Sequence
weights to the internal classes.w
- the array of weights