|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.classifier.AbstractClassifier
public abstract class AbstractClassifier
The super class for any classifier.
The order of the classes is never changed inside the classifier. The samples you put in the methods
like train, test
and evaluate
should always have the same order that you have used while
instantiation of the object.
For two classes it is highly recommended to set the foreground as first class and the second class as background.
Constructor Summary | |
---|---|
AbstractClassifier(AlphabetContainer abc)
The constructor for a homogeneous classifier. |
|
AbstractClassifier(AlphabetContainer abc,
int length)
The constructor for an inhomogeneous classifier. |
|
AbstractClassifier(StringBuffer xml)
The constructor for the Storable interface. |
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. |
abstract byte |
classify(Sequence seq)
This method classifies a sequence and returns the index i , with
0 < i < getNumberOfClasses() , of the class to which the sequence is assigned. |
AbstractClassifier |
clone()
|
NumericalResultSet |
evaluate(MeasureParameters params,
boolean exceptionIfNotComputeable,
Sample... s)
This method evaluates the classifier and computes all numerical results as for instance the sensitivity for a given specificity, the area under ROC curve and so on. |
ResultSet |
evaluateAll(MeasureParameters params,
boolean exceptionIfNotComputeable,
Sample... s)
This method evaluates the classifier and computes all results. |
protected abstract void |
extractFurtherClassifierInfosFromXML(StringBuffer xml)
Extracts further information of a classifier from an xml-representation. |
AlphabetContainer |
getAlphabetContainer()
This method return the container of alphabets that is used in the classifier. |
ResultSet |
getCharacteristics()
Returns some information characterizing or describing the current instance of the model. |
protected NumericalResult |
getClassificationRate(Sample[] s)
This method computes the classification rate for a given array of samples. |
abstract CategoricalResult[] |
getClassifierAnnotation()
Returns an array of Results of dimension getNumberOfClasses that contains information the
classifier and for each class. |
protected abstract StringBuffer |
getFurtherClassifierInfos()
This method returns further information of a classifier as a StringBuffer. |
abstract String |
getInstanceName()
Returns a short description of the classifier. |
int |
getLength()
Returns the length of the sequences this classifier can handle or 0 for sequences of arbitrary
length. |
static MeasureParameters |
getMeasuresForEvaluate()
Returns an object of the parameters for the evaluate-method. |
static MeasureParameters |
getMeasuresForEvaluateAll()
Returns an object of the parameters for the evaluateAll-method. |
abstract int |
getNumberOfClasses()
Returns the number of classes that can be distinguished. |
abstract NumericalResultSet |
getNumericalCharacteristics()
Returns the subset of numerical values that are also returned by getCharacteristsics . |
protected LinkedList<? extends Result> |
getResults(Sample[] s,
MeasureParameters params,
boolean exceptionIfNotComputeable,
boolean all)
This method computes the results for any evaluation of the classifier. |
protected abstract String |
getXMLTag()
Returns the String that is used as tag for the xml-representation. |
abstract 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. |
ConfusionMatrix |
test(Sample... testData)
This method computes the confusion matrix for a given array of test data |
StringBuffer |
toXML()
This method returns an XML-representation of an instance of the implementing class. |
void |
train(Sample... s)
Trains the AbstractClassifier object given the data as Sample s. |
abstract void |
train(Sample[] s,
double[][] weights)
This method trains a classifier over an array of weighted Sample s. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractClassifier(AlphabetContainer abc)
abc
- public AbstractClassifier(AlphabetContainer abc, int length) throws IllegalArgumentException
abc
- the alphabets that are used forlength
- the length of the sequences that can be classified
IllegalArgumentException
- if the length and the possible length of the AlphabetContainer does not matchpublic AbstractClassifier(StringBuffer xml) throws NonParsableException
xml
- the xml-representation
NonParsableException
- if the xml-format is not parsableMethod Detail |
---|
public static final MeasureParameters getMeasuresForEvaluate() throws ParameterException
ParameterException
evaluate(MeasureParameters, boolean, Sample...)
public static final MeasureParameters getMeasuresForEvaluateAll() throws ParameterException
ParameterException
evaluateAll(MeasureParameters, boolean, Sample...)
public abstract byte classify(Sequence seq) throws Exception
i
, with
0 < i < getNumberOfClasses()
, of the class to which the sequence is assigned.
seq
- the sequence to be classified
Exception
- if the classifier is not trained or something is wrong with the sequencepublic byte[] classify(Sample s) throws Exception
i
, with
0 < i < getNumberOfClasses()
, of the class to which the sequence is assigned.
s
- the sample to be classified
Exception
- if something went wrong while classificationpublic AbstractClassifier clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public final NumericalResultSet evaluate(MeasureParameters params, boolean exceptionIfNotComputeable, Sample... s) throws Exception
params
- the current parametersexceptionIfNotComputeable
- if true
the methods
- the array of Samples
Exception
- if something went wrongClassifierAssessment.assess(MeasureParameters, ClassifierAssessmentAssessParameterSet, ProgressUpdater, Sample[])
,
ClassifierAssessment.assess(MeasureParameters, ClassifierAssessmentAssessParameterSet, Sample[])
,
ClassifierAssessment.assess(MeasureParameters, ClassifierAssessmentAssessParameterSet, ProgressUpdater, Sample[][][])
public final ResultSet evaluateAll(MeasureParameters params, boolean exceptionIfNotComputeable, Sample... s) throws Exception
params
- the current parametersexceptionIfNotComputeable
- if true
the method throws an exception if a measure could not be computed, otherwise it
is ignoreds
- the array of Samples
Exception
- if something went wrongprotected LinkedList<? extends Result> getResults(Sample[] s, MeasureParameters params, boolean exceptionIfNotComputeable, boolean all) throws Exception
s
- the array of Samplesparams
- the current parametersexceptionIfNotComputeable
- if true
the method throws an exception if a measure could not be computed, otherwise it
is ignoredall
- if true
the method computes all results, if false
it computes only the
numerical results
Exception
- if something went wrongevaluate(MeasureParameters, boolean, Sample...)
,
evaluateAll(MeasureParameters, boolean, Sample...)
protected final NumericalResult getClassificationRate(Sample[] s) throws Exception
s
- the array of samples; sample 0 contains only elements of class 0; sample 1 ...
Exception
- if something went wrong while classificationpublic final AlphabetContainer getAlphabetContainer()
public ResultSet getCharacteristics() throws Exception
ObjectResult
Exception
- an Exception
is thrown if some of the characteristics could not be definedStorableResult
public abstract String getInstanceName()
public abstract CategoricalResult[] getClassifierAnnotation()
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" );
...
public final int getLength()
0
for sequences of arbitrary
length.
public abstract NumericalResultSet getNumericalCharacteristics() throws Exception
getCharacteristsics
.
Exception
- an Exception
is thrown if some of the characteristics could not be definedpublic abstract int getNumberOfClasses()
public abstract boolean isTrained()
true
if the classifier is able to classify sequences, otherwise false
public boolean setNewAlphabetContainerInstance(AlphabetContainer abc)
abc
- the alphabets
true
if the new container could be setgetAlphabetContainer()
,
AlphabetContainer.checkConsistency(AlphabetContainer)
public ConfusionMatrix test(Sample... testData) throws Exception, ClassDimensionException
testData
- the data
ClassDimensionException
- if the number of samples in incorrect
Exception
- if something went wrongpublic void train(Sample... s) throws Exception
Sample
s.train(data1); train(data2);
should be a fully trained model over data2
and not over
data1, data2
.
Sample
s are defined over the underlying alphabet and length.
s
- the data
Sample
s: train( new Sample[]{s1,s2,s3})
or
Sample
s: train(s1,s2,s3)
Exception
- an Exception should be thrown if the training did not succeedpublic abstract void train(Sample[] s, double[][] weights) throws Exception
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.
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 abstract String getXMLTag()
fromXML( StringBuffer )
and toXML()
.
protected abstract void extractFurtherClassifierInfosFromXML(StringBuffer xml) throws NonParsableException
fromXML( StringBuffer )
and should not be made public.
xml
- the xml-representation
NonParsableException
public final StringBuffer toXML()
Storable
toXML
in interface Storable
protected abstract StringBuffer getFurtherClassifierInfos()
toXML()
and should not be made public.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |