|
||||||||||
| 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 returns 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 about 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 getCharacteristics(). |
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 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. |
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
Samples. |
abstract void |
train(Sample[] s,
double[][] weights)
This method trains a classifier over an array of weighted Samples. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractClassifier(AlphabetContainer abc)
abc - the AlphabetContainer
public AbstractClassifier(AlphabetContainer abc,
int length)
throws IllegalArgumentException
abc - the alphabets that are usedlength - the length of the sequences that can be classified
IllegalArgumentException - if the length and the possible length of the
AlphabetContainer does not match
public AbstractClassifier(StringBuffer xml)
throws NonParsableException
Storable interface.
xml - the XML representation
NonParsableException - if the XML format is not parsable| Method Detail |
|---|
public static final MeasureParameters getMeasuresForEvaluate()
throws ParameterException
evaluate-method.
The parameters can be set and the measures can be switched on or off.
evaluate-method
ParameterException - if something went wrong while constructing the parameter
objectevaluate(MeasureParameters, boolean, Sample...)
public static final MeasureParameters getMeasuresForEvaluateAll()
throws ParameterException
evaluateAll
-method. The parameters can be set and the measures can be switched on or
off.
evaluateAll
-method
ParameterException - if something went wrong while constructing the parameter
objectevaluateAll(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 sequence
public 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 classification
public AbstractClassifier clone()
throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedException
public final NumericalResultSet evaluate(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 wrongClassifierAssessment.assess(MeasureParameters,
de.jstacs.classifier.assessment.ClassifierAssessmentAssessParameterSet,
de.jstacs.utils.ProgressUpdater, Sample...),
ClassifierAssessment.assess(MeasureParameters,
de.jstacs.classifier.assessment.ClassifierAssessmentAssessParameterSet,
Sample...),
ClassifierAssessment.assess(MeasureParameters,
de.jstacs.classifier.assessment.ClassifierAssessmentAssessParameterSet,
de.jstacs.utils.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 wrong
protected 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 definedStorableResultpublic abstract String getInstanceName()
public abstract CategoricalResult[] getClassifierAnnotation()
Results of dimension
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" );
...
Results that contains information the
classifierpublic final int getLength()
0 for sequences of arbitrary length.
public abstract NumericalResultSet getNumericalCharacteristics()
throws Exception
getCharacteristics().
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 falsepublic boolean setNewAlphabetContainerInstance(AlphabetContainer abc)
AlphabetContainer
for the current model. This instance has to be consistent with the
underlying instance of an AlphabetContainer.
abc - the alphabets
true if the new container could be setgetAlphabetContainer(),
AlphabetContainer.checkConsistency(AlphabetContainer)
public ConfusionMatrix test(Sample... testData)
throws Exception,
ClassDimensionException
testData - the given array of test data
ClassDimensionException - if the number of samples in incorrect
Exception - if something went wrong
public void train(Sample... s)
throws Exception
AbstractClassifier object given the data as
Samples.train(data1); train(data2); should be a
fully trained model over data2 and not over
data1, data2.
Samples are defined over
the underlying alphabet and length.
public abstract void train(Sample[] s,
double[][] weights)
throws Exception
Samples. 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.
s - 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 abstract String getXMLTag()
String that is used as tag for the XML
representation. This method is used by the methods
fromXML(StringBuffer) and toXML().
String that is used as tag for the XML representation
protected abstract void extractFurtherClassifierInfosFromXML(StringBuffer xml)
throws NonParsableException
fromXML(StringBuffer) and
should not be made public.
xml - XML representation
NonParsableException - if the information could not be parsed out of the
StringBufferpublic final StringBuffer toXML()
Storable
toXML in interface Storableprotected abstract StringBuffer getFurtherClassifierInfos()
StringBuffer. This method is used by the method toXML()
and should not be made public.
StringBuffer
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||