|
||||||||||
| 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.modelBased.ModelBasedClassifier
public class ModelBasedClassifier
This class is the main class for all model based classifiers. The score for
this class is the logarithm of the joint probability
p(x,c|\lambda).
Model| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class de.jstacs.classifier.AbstractScoreBasedClassifier |
|---|
AbstractScoreBasedClassifier.DoubleTableResult |
| Field Summary | |
|---|---|
protected Model[] |
models
The internal models. |
| Constructor Summary | |
|---|---|
protected |
ModelBasedClassifier(boolean cloneModels,
Model... models)
This constructor creates a new instance with the given models and clones these if necessary. |
|
ModelBasedClassifier(Model... models)
The default constructor. |
|
ModelBasedClassifier(StringBuffer xml)
This is the constructor for the interface Storable. |
| Method Summary | |
|---|---|
byte[] |
classify(Sample s)
This method classifies all sequences of a sample and returns the index i, with 0 < i < getNumberOfClasses(), of
the class to which the sequence is assigned. |
ModelBasedClassifier |
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 model. |
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. |
Model |
getModel(int classIndex)
Returns a clone of the model for a specified class. |
NumericalResultSet |
getNumericalCharacteristics()
Returns the subset of numerical values that are also returned by AbstractClassifier.getCharacteristics(). |
static int |
getPossibleLength(Model... models)
This method returns the possible length of a classifier that would use the given models. |
protected double |
getScore(Sequence seq,
int i,
boolean check)
This method returns the score for a given sequence and a given class. |
double[] |
getScores(Sample s)
This method returns the scores of the classifier for any sequence in the sample. |
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. |
boolean |
setNewAlphabetContainerInstance(AlphabetContainer abc)
This method tries to set a new instance of an AlphabetContainer
for the current model. |
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, createDefaultClassWeights, getClassWeight, getClassWeights, getNumberOfClasses, getPValue, getPValue, getResults, getScore, setClassWeights, setThresholdClassWeights, test |
| Methods inherited from class de.jstacs.classifier.AbstractClassifier |
|---|
evaluate, evaluateAll, getAlphabetContainer, getClassificationRate, getLength, getMeasuresForEvaluate, getMeasuresForEvaluateAll, toXML, train |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Model[] models
| Constructor Detail |
|---|
protected ModelBasedClassifier(boolean cloneModels,
Model... models)
throws IllegalArgumentException,
CloneNotSupportedException,
ClassDimensionException
cloneModels - a switch to decide whether to clone the model or notmodels - the models
IllegalArgumentException - if the models do not describe a common domain of sequences
CloneNotSupportedException - if at least one model could not be cloned
ClassDimensionException - if the number of classes is below 2
public ModelBasedClassifier(Model... models)
throws IllegalArgumentException,
CloneNotSupportedException,
ClassDimensionException
models - the models
IllegalArgumentException - if the models do not describe a common domain of sequences
CloneNotSupportedException - if at least one model could not be cloned
ClassDimensionException - if the number of classes is below 2
public ModelBasedClassifier(StringBuffer xml)
throws NonParsableException
Storable.
xml - the XML representation
NonParsableException - if the representation could not be parsed.| Method Detail |
|---|
public static int getPossibleLength(Model... models)
throws IllegalArgumentException
models - the models that will be tested
IllegalArgumentException - if no classifier could be created, since the models have
incompatible lengths
public ModelBasedClassifier clone()
throws CloneNotSupportedException
clone in class AbstractScoreBasedClassifierCloneNotSupportedException
public ResultSet getCharacteristics()
throws Exception
AbstractClassifierObjectResult.
getCharacteristics in class AbstractClassifierException - an Exception is thrown if some of the
characteristics could not be definedStorableResultpublic String getInstanceName()
AbstractClassifier
getInstanceName in class AbstractClassifier
public Model getModel(int classIndex)
throws CloneNotSupportedException
classIndex - the index of the specified class
CloneNotSupportedException - if the model could not be cloned
public NumericalResultSet getNumericalCharacteristics()
throws Exception
AbstractClassifierAbstractClassifier.getCharacteristics().
getNumericalCharacteristics in class AbstractClassifierException - an Exception is thrown if some of the
characteristics could not be definedpublic boolean isTrained()
AbstractClassifier
isTrained in class AbstractClassifiertrue if the classifier is able to classify
sequences, otherwise falsepublic final boolean setNewAlphabetContainerInstance(AlphabetContainer abc)
AbstractClassifierAlphabetContainer
for the current model. This instance has to be consistent with the
underlying instance of an AlphabetContainer.
setNewAlphabetContainerInstance in class AbstractClassifierabc - the alphabets
true if the new container could be setAbstractClassifier.getAlphabetContainer(),
AlphabetContainer.checkConsistency(AlphabetContainer)
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 succeedprotected 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 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
NotTrainedException - if the classifier is not trained
IllegalArgumentException - if something is wrong with seq
Exception - if something went wrong
public double[] getScores(Sample s)
throws Exception
AbstractScoreBasedClassifier
getScores in class AbstractScoreBasedClassifiers - the sample
Exception - if something went wrong
public byte[] classify(Sample s)
throws Exception
AbstractClassifieri, with 0 < i < getNumberOfClasses(), of
the class to which the sequence is assigned.
classify in class AbstractClassifiers - the sample to be classified
Exception - if something went wrong while classificationprotected 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 representation
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
StringBufferpublic 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
classifier
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||