|
||||||||||
| 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 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(). |
abstract byte |
classify(Sequence seq)
This method classifies a sequence and returns the index i of
the class to which the sequence is assigned with
0 < i < getNumberOfClasses(). |
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 the 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 classifier. |
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 method evaluate(MeasureParameters, boolean, Sample...). |
static MeasureParameters |
getMeasuresForEvaluateAll()
Returns an object of the parameters for the method evaluateAll(MeasureParameters, boolean, Sample...). |
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
of the classifier. |
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 classifier. |
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 as StringBuffer 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 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 - the alphabets that are usedAbstractClassifier(AlphabetContainer, int)
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.
Creates a new AbstractClassifier out of its XML representation.
xml - the XML representation as StringBuffer
NonParsableException - if the AbstractClassifier could not be reconstructed
out of the XML representation (the StringBuffer could
not be parsed)Storable| Method Detail |
|---|
public static final MeasureParameters getMeasuresForEvaluate()
throws ParameterException
evaluate(MeasureParameters, boolean, Sample...). The parameters
can be set and the measures can be switched on or off.
evaluate(MeasureParameters, boolean, Sample...)
ParameterException - if something went wrong while constructing the parameter
objectevaluate(MeasureParameters, boolean, Sample...),
MeasureParameters.MeasureParameters(boolean)
public static final MeasureParameters getMeasuresForEvaluateAll()
throws ParameterException
evaluateAll(MeasureParameters, boolean, Sample...). The
parameters can be set and the measures can be switched on or off.
evaluateAll(MeasureParameters, boolean, Sample...)
ParameterException - if something went wrong while constructing the parameter
objectevaluateAll(MeasureParameters, boolean,
Sample...),
MeasureParameters.MeasureParameters(boolean)
public abstract byte classify(Sequence seq)
throws Exception
i of
the class to which the sequence is assigned with
0 < i < getNumberOfClasses().
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 in the array
0 < i < getNumberOfClasses().
s - the sample to be classified
Exception - if something went wrong during the 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 - indicates the method throws an Exception if a measure
could not be computeds - the array of Samples
Exception - if something went wrongNumericalResultSet.NumericalResultSet(LinkedList),
getResults(Sample[], MeasureParameters, boolean,
boolean),
ClassifierAssessment.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 - indicates the method throws an Exception if a measure
could not be computeds - the array of Samples
Exception - if something went wrongResultSet.ResultSet(java.util.Collection),
getResults(Sample[], MeasureParameters, boolean,
boolean)
protected LinkedList<? extends Result> getResults(Sample[] s,
MeasureParameters params,
boolean exceptionIfNotComputeable,
boolean all)
throws Exception
s - the array of Samplesparams - the current parametersexceptionIfNotComputeable - indicates the method throws an Exception if a measure
could not be computedall - indicates the method computes all results or 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 during the classificationpublic final AlphabetContainer getAlphabetContainer()
public ResultSet getCharacteristics()
throws Exception
StorableResult.
Exception - if some of the characteristics could not be definedStorableResult,
getNumericalCharacteristics(),
ResultSet.ResultSet(de.jstacs.results.Result[][])public 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 about the
classifierpublic final int getLength()
0 for sequences of arbitrary length.
public abstract NumericalResultSet getNumericalCharacteristics()
throws Exception
getCharacteristics().
Exception - if some of the characteristics could not be definedpublic abstract int getNumberOfClasses()
public abstract boolean isTrained()
true if the classifier is trained and therefore able
to classify sequences, otherwise falsepublic boolean setNewAlphabetContainerInstance(AlphabetContainer abc)
AlphabetContainer
for the current classifier. AlphabetContainer.
abc - the alphabets
true if the new AlphabetContainer could be
set, false otherwisegetAlphabetContainer(),
AlphabetContainer.checkConsistency(AlphabetContainer)
public ConfusionMatrix test(Sample... testData)
throws Exception,
ClassDimensionException
testData - the given array of test data
ClassDimensionException - if the number of Samples is incorrect
Exception - if something else 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
Sample
s. 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 the Samples
Exception - if the weights are incorrect or the training did not succeedtrain(Sample...)protected abstract String getXMLTag()
String that is used as tag for the XML representation
of the classifier. This method is used by the methods
fromXML(StringBuffer) and toXML().
String that is used as tag for the XML representation
of the classifier
protected abstract void extractFurtherClassifierInfosFromXML(StringBuffer xml)
throws NonParsableException
fromXML(StringBuffer) and
should not be made public.
xml - the XML representation as StringBuffer
NonParsableException - if the information could not be parsed out of the XML
representation (the StringBuffer could not be parsed)fromXML(StringBuffer)public final StringBuffer toXML()
StorableStringBuffer of an
instance of the implementing class.
toXML in interface Storableprotected abstract StringBuffer getFurtherClassifierInfos()
StringBuffer. This method is used by the method toXML()
and should not be made public.
StringBuffertoXML()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||