|
||||||||||
| 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 that creates a new instance with the given Models. |
|
ModelBasedClassifier(StringBuffer xml)
The standard constructor for the interface Storable. |
| Method Summary | |
|---|---|
byte[] |
classify(Sample 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(). |
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 classifier. |
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
of the classifier. |
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 classifier. |
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, createDefaultClassWeights, getClassWeight, getClassWeights, getNumberOfClasses, getPValue, getPValue, getResults, getScore, setClassWeights, 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
Models. Model 0 handles class 0;
Model 1 handles class 1 ... etc.
| Constructor Detail |
|---|
protected ModelBasedClassifier(boolean cloneModels,
Model... models)
throws IllegalArgumentException,
CloneNotSupportedException,
ClassDimensionException
Models and
clones these if necessary.
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 2AbstractScoreBasedClassifier.AbstractScoreBasedClassifier(AlphabetContainer,
int, int, double)
public ModelBasedClassifier(Model... models)
throws IllegalArgumentException,
CloneNotSupportedException,
ClassDimensionException
Models.
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 2ModelBasedClassifier(boolean, Model...)
public ModelBasedClassifier(StringBuffer xml)
throws NonParsableException
Storable.
Constructs a ModelBasedClassifier out of its XML representation.
xml - the XML representation as StringBuffer
NonParsableException - if the ModelBasedClassifier 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(Model... models)
throws IllegalArgumentException
Models.
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
AbstractClassifierStorableResult.
getCharacteristics in class AbstractClassifierException - 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 Model getModel(int classIndex)
throws CloneNotSupportedException
Model for a specified class.
classIndex - the index of the specified class
Model of the specified class
CloneNotSupportedException - if the Model could not be clonedModel.clone()
public NumericalResultSet getNumericalCharacteristics()
throws Exception
AbstractClassifierAbstractClassifier.getCharacteristics().
getNumericalCharacteristics in class AbstractClassifierException - if some of the characteristics could not be definedpublic boolean isTrained()
AbstractClassifier
isTrained in class AbstractClassifiertrue if the classifier is trained and therefore able
to classify sequences, otherwise falsepublic final boolean setNewAlphabetContainerInstance(AlphabetContainer abc)
AbstractClassifierAlphabetContainer
for the current classifier. AlphabetContainer.
setNewAlphabetContainerInstance in class AbstractClassifierabc - the alphabets
true if the new AlphabetContainer could be
set, false otherwiseAbstractClassifier.getAlphabetContainer(),
AlphabetContainer.checkConsistency(AlphabetContainer)
public void train(Sample[] s,
double[][] weights)
throws Exception
AbstractClassifierSample
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(Sample...).
Samples are defined over the
underlying alphabet and length.
train in class AbstractClassifiers - an array of Samplesweights - the weights for the Samples
Exception - if the weights are incorrect or the training did not succeedAbstractClassifier.train(Sample...)protected StringBuffer getFurtherClassifierInfos()
AbstractClassifierStringBuffer. This method is used by the method AbstractClassifier.toXML()
and should not be made public.
getFurtherClassifierInfos in class AbstractScoreBasedClassifierStringBufferAbstractClassifier.toXML()
protected double getScore(Sequence seq,
int i,
boolean check)
throws Exception
AbstractScoreBasedClassifierSequence and a given
class.
getScore in class AbstractScoreBasedClassifierseq - the Sequencei - 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 wrong
public double[] getScores(Sample s)
throws Exception
AbstractScoreBasedClassifierSequence
in the Sample. The scores are stored in the array according to
the index of the Sequence in the Sample.
getScores in class AbstractScoreBasedClassifiers - the Sample
Exception - if something went wrong
public byte[] classify(Sample s)
throws Exception
AbstractClassifieri in the array
0 < i < getNumberOfClasses().
classify in class AbstractClassifiers - the sample to be classified
Exception - if something went wrong during the classificationprotected String getXMLTag()
AbstractClassifierString 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 AbstractClassifierString that is used as tag for the XML representation
of the classifier
protected void extractFurtherClassifierInfosFromXML(StringBuffer xml)
throws NonParsableException
AbstractClassifierAbstractClassifier.fromXML(StringBuffer) and
should not be made public.
extractFurtherClassifierInfosFromXML in class AbstractScoreBasedClassifierxml - 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()
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 about the
classifier
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||