|
||||||||||
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.trainSMBased.TrainSMBasedClassifier
public class TrainSMBasedClassifier
Classifier that works on TrainableStatisticalModel
s for each of the different classes.
By calling the AbstractClassifier.train(DataSet...)
method of this classifier,
all internal TrainableStatisticalModel
s are learned on the DataSet
for the corresponding class
using their own TrainableStatisticalModel.train(DataSet)
method. In addition, the a-priori class
probabilities are estimated.
After training, the method AbstractScoreBasedClassifier.getScore(Sequence, int)
returns the joint
probability (likelihood) of the provided Sequence
and the specified class.
For two-class problems, the method getScores(DataSet)
returns the log-likelihood ratios for
all Sequence
s in the provided DataSet
.
The methods AbstractScoreBasedClassifier.classify(Sequence)
and classify(DataSet)
use the likelihoods of Sequence
and class and report the class yielding the maximum likelihood.
TrainableStatisticalModel
Nested Class Summary |
---|
Nested classes/interfaces inherited from class de.jstacs.classifiers.AbstractScoreBasedClassifier |
---|
AbstractScoreBasedClassifier.DoubleTableResult |
Field Summary | |
---|---|
protected TrainableStatisticalModel[] |
models
The internal TrainableStatisticalModel s. |
Constructor Summary | |
---|---|
protected |
TrainSMBasedClassifier(boolean cloneModels,
TrainableStatisticalModel... models)
This constructor creates a new instance with the given TrainableStatisticalModel s and
clones these if necessary. |
|
TrainSMBasedClassifier(StringBuffer xml)
The standard constructor for the interface Storable . |
|
TrainSMBasedClassifier(TrainableStatisticalModel... models)
The default constructor that creates a new instance with the given TrainableStatisticalModel s. |
Method Summary | |
---|---|
byte[] |
classify(DataSet s)
This method classifies all sequences of a sample and returns an array of indices of the classes to which the respective sequences are assigned with for each index i in the array
0 < i < getNumberOfClasses() . |
TrainSMBasedClassifier |
clone()
|
protected void |
extractFurtherClassifierInfosFromXML(StringBuffer xml)
Extracts further information of a classifier from an XML representation. |
ResultSet |
getCharacteristics()
Returns some information characterizing or describing the current instance of the classifier. |
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. |
TrainableStatisticalModel |
getModel(int classIndex)
Returns a clone of the TrainableStatisticalModel for a specified class. |
NumericalResultSet |
getNumericalCharacteristics()
Returns the subset of numerical values that are also returned by AbstractClassifier.getCharacteristics() . |
static int |
getPossibleLength(TrainableStatisticalModel... models)
This method returns the possible length of a classifier that would use the given TrainableStatisticalModel s. |
protected double |
getScore(Sequence seq,
int i,
boolean check)
This method returns the score for a given Sequence and a given
class. |
double[] |
getScores(DataSet s)
This method returns the scores of the classifier for any Sequence
in the DataSet . |
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. |
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, createDefaultClassWeights, getClassWeight, getClassWeights, getMultiClassScores, getNumberOfClasses, getPValue, getPValue, getResults, getScore, setClassWeights, setClassWeights, setThresholdClassWeights |
Methods inherited from class de.jstacs.classifiers.AbstractClassifier |
---|
evaluate, getAlphabetContainer, getLength, toXML, train |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected TrainableStatisticalModel[] models
TrainableStatisticalModel
s. TrainableStatisticalModel
0 handles class 0;
TrainableStatisticalModel
1 handles class 1 ... etc.
Constructor Detail |
---|
protected TrainSMBasedClassifier(boolean cloneModels, TrainableStatisticalModel... models) throws IllegalArgumentException, CloneNotSupportedException, ClassDimensionException
TrainableStatisticalModel
s and
clones these if necessary.
cloneModels
- a switch to decide whether to clone the TrainableStatisticalModel
or notmodels
- the TrainableStatisticalModel
s
IllegalArgumentException
- if the TrainableStatisticalModel
s do not describe a common domain of
sequences
CloneNotSupportedException
- if at least one TrainableStatisticalModel
could not be cloned
ClassDimensionException
- if the number of classes is below 2AbstractScoreBasedClassifier.AbstractScoreBasedClassifier(AlphabetContainer,
int, int, double)
public TrainSMBasedClassifier(TrainableStatisticalModel... models) throws IllegalArgumentException, CloneNotSupportedException, ClassDimensionException
TrainableStatisticalModel
s.
models
- the TrainableStatisticalModel
s
IllegalArgumentException
- if the TrainableStatisticalModel
s do not describe a common domain of
sequences
CloneNotSupportedException
- if at least one TrainableStatisticalModel
could not be cloned
ClassDimensionException
- if the number of classes is below 2TrainSMBasedClassifier(boolean, TrainableStatisticalModel...)
public TrainSMBasedClassifier(StringBuffer xml) throws NonParsableException
Storable
.
Constructs a TrainSMBasedClassifier
out of its XML representation.
xml
- the XML representation as StringBuffer
NonParsableException
- if the TrainSMBasedClassifier
could not be
reconstructed out of the XML representation (the
StringBuffer
could not be parsed)AbstractScoreBasedClassifier.AbstractScoreBasedClassifier(StringBuffer)
,
Storable
Method Detail |
---|
public static int getPossibleLength(TrainableStatisticalModel... models) throws IllegalArgumentException
TrainableStatisticalModel
s.
models
- the TrainableStatisticalModel
s that will be tested
IllegalArgumentException
- if no classifier could be created since the TrainableStatisticalModel
s
have incompatible lengthspublic TrainSMBasedClassifier clone() throws CloneNotSupportedException
clone
in class AbstractScoreBasedClassifier
CloneNotSupportedException
public ResultSet getCharacteristics() throws Exception
AbstractClassifier
StorableResult
.
getCharacteristics
in class AbstractClassifier
Exception
- if some of the characteristics could not be definedStorableResult
,
AbstractClassifier.getNumericalCharacteristics()
,
ResultSet.ResultSet(de.jstacs.results.Result[][])
public String getInstanceName()
AbstractClassifier
getInstanceName
in class AbstractClassifier
public TrainableStatisticalModel getModel(int classIndex) throws CloneNotSupportedException
TrainableStatisticalModel
for a specified class.
classIndex
- the index of the specified class
TrainableStatisticalModel
of the specified class
CloneNotSupportedException
- if the TrainableStatisticalModel
could not be clonedTrainableStatisticalModel.clone()
public NumericalResultSet getNumericalCharacteristics() throws Exception
AbstractClassifier
AbstractClassifier.getCharacteristics()
.
getNumericalCharacteristics
in class AbstractClassifier
Exception
- if some of the characteristics could not be definedpublic 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 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 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
NotTrainedException
- if the classifier is not trained
IllegalArgumentException
- if something is wrong with the Sequence
seq
Exception
- if something went wrongpublic double[] getScores(DataSet s) throws Exception
AbstractScoreBasedClassifier
Sequence
in the DataSet
. The scores are stored in the array according to
the index of the Sequence
in the DataSet
.
getScores
in class AbstractScoreBasedClassifier
s
- the DataSet
Exception
- if something went wrongpublic byte[] classify(DataSet s) throws Exception
AbstractClassifier
i
in the array
0 < i < getNumberOfClasses()
.
classify
in class AbstractClassifier
s
- the sample to be classified
Exception
- if something went wrong during the classificationprotected 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 classifierprotected 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)
public 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
classifier
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |