|
||||||||||
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 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 getNumberOfClasses that contains information 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 getCharacteristsics . |
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 the state of the classifier. |
boolean |
setNewAlphabetContainerInstance(AlphabetContainer abc)
This method tries to set a new instance of an AlphabetConatiner for the current model. |
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, 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 2public 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 2public 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 lengthspublic ModelBasedClassifier clone() throws CloneNotSupportedException
clone
in class AbstractScoreBasedClassifier
CloneNotSupportedException
public ResultSet getCharacteristics() throws Exception
AbstractClassifier
ObjectResult
getCharacteristics
in class AbstractClassifier
Exception
- an Exception
is thrown if some of the characteristics could not be definedStorableResult
public 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 clonedpublic NumericalResultSet getNumericalCharacteristics() throws Exception
AbstractClassifier
getCharacteristsics
.
getNumericalCharacteristics
in class AbstractClassifier
Exception
- an Exception
is thrown if some of the characteristics could not be definedpublic boolean isTrained()
AbstractClassifier
isTrained
in class AbstractClassifier
true
if the classifier is able to classify sequences, otherwise false
public final boolean setNewAlphabetContainerInstance(AlphabetContainer abc)
AbstractClassifier
setNewAlphabetContainerInstance
in class AbstractClassifier
abc
- the alphabets
true
if the new container could be setAbstractClassifier.getAlphabetContainer()
,
AlphabetContainer.checkConsistency(AlphabetContainer)
public void train(Sample[] s, double[][] weights) throws Exception
AbstractClassifier
Sample
s. That's why the following has
to be fulfilled:
s.length == weights.length
weights[i] == null || s[i].getNumberOfElements() == weights[i].length
.
train( Sample[] )
.
Sample
s are defined over the underlying alphabet and length.
train
in class AbstractClassifier
s
- an array of Sample
sweights
- the weights for s
Exception
- an Exception should be thrown if the weights are incorrect or the training did not succeedprotected StringBuffer getFurtherClassifierInfos()
AbstractClassifier
toXML()
and should not be made public.
getFurtherClassifierInfos
in class AbstractScoreBasedClassifier
protected double getScore(Sequence seq, int i, boolean check) throws Exception
AbstractScoreBasedClassifier
getScore
in class AbstractScoreBasedClassifier
seq
- the sequencei
- the index of the classcheck
- the switch to decide whether to check AlphabetContainer and length of the sequence or not
NotTrainedException
IllegalArgumentException
Exception
public double[] getScores(Sample s) throws Exception
AbstractScoreBasedClassifier
getScores
in class AbstractScoreBasedClassifier
s
- the sample
Exception
- if something went wrongpublic byte[] classify(Sample s) throws Exception
AbstractClassifier
i
, with
0 < i < getNumberOfClasses()
, of the class to which the sequence is assigned.
classify
in class AbstractClassifier
s
- the sample to be classified
Exception
- if something went wrong while classificationprotected String getXMLTag()
AbstractClassifier
fromXML( StringBuffer )
and toXML()
.
getXMLTag
in class AbstractClassifier
protected void extractFurtherClassifierInfosFromXML(StringBuffer xml) throws NonParsableException
AbstractClassifier
fromXML( StringBuffer )
and should not be made public.
extractFurtherClassifierInfosFromXML
in class AbstractScoreBasedClassifier
xml
- the xml-representation
NonParsableException
public CategoricalResult[] getClassifierAnnotation()
AbstractClassifier
getNumberOfClasses
that contains information 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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |