|
||||||||||
| 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
public abstract class AbstractScoreBasedClassifier
This class is the main class for all score based classifiers. Score based classifiers enable you to compute many different measures easily. For instance one can use the package "ROCR" in R to compute or plot many of them.
| Nested Class Summary | |
|---|---|
static class |
AbstractScoreBasedClassifier.DoubleTableResult
This class is for a table of doubles. |
| Constructor Summary | |
|---|---|
AbstractScoreBasedClassifier(AlphabetContainer abc,
int classes)
The constructor for a homogeneous classifier. |
|
AbstractScoreBasedClassifier(AlphabetContainer abc,
int classes,
double classWeight)
The constructor for a homogeneous classifier. |
|
AbstractScoreBasedClassifier(AlphabetContainer abc,
int length,
int classes)
The constructor for an inhomogeneous classifier. |
|
AbstractScoreBasedClassifier(AlphabetContainer abc,
int length,
int classes,
double classWeight)
The constructor for an inhomogeneous classifier. |
|
AbstractScoreBasedClassifier(StringBuffer xml)
The constructor for the Storable interface. |
|
| Method Summary | |
|---|---|
protected void |
check(Sample s)
This method checks if the given Sample can be used. |
protected void |
check(Sequence seq)
This method checks if the given sequence can be used. |
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. |
protected byte |
classify(Sequence seq,
boolean check)
This method classifies a sequence. |
AbstractScoreBasedClassifier |
clone()
|
protected void |
createDefaultClassWeights(int classes,
double val)
This method creates new class weights. |
protected void |
extractFurtherClassifierInfosFromXML(StringBuffer xml)
Extracts further information of a classifier from an XML representation. |
protected double |
getClassWeight(int index)
Returns the class weight for class index. |
double[] |
getClassWeights()
Returns the specific class weights of a AbstractScoreBasedClassifier. |
protected StringBuffer |
getFurtherClassifierInfos()
This method returns further information of a classifier as a StringBuffer. |
int |
getNumberOfClasses()
Returns the number of classes that can be distinguished. |
double[] |
getPValue(Sample candidates,
Sample bg)
Returns the p-values for all sequence in candidates with
respect to a given background sample. |
double |
getPValue(Sequence candidate,
Sample bg)
Returns the p-value for a sequence candidate with respect to
a given background sample. |
protected LinkedList<? extends Result> |
getResults(Sample[] s,
MeasureParameters params,
boolean exceptionIfNotComputeable,
boolean all)
This method computes the results for any evaluation of the classifier. |
double |
getScore(Sequence seq,
int i)
This method returns the score for a given sequence and a given class. |
protected abstract 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. |
void |
setClassWeights(boolean add,
double... weights)
Sets new class weights. |
void |
setThresholdClassWeights(boolean add,
double t)
Sets a new threshold for 2-class-classifiers. |
ConfusionMatrix |
test(Sample... testData)
This method computes the confusion matrix for a given array of test data. |
| Methods inherited from class de.jstacs.classifier.AbstractClassifier |
|---|
classify, evaluate, evaluateAll, getAlphabetContainer, getCharacteristics, getClassificationRate, getClassifierAnnotation, getInstanceName, getLength, getMeasuresForEvaluate, getMeasuresForEvaluateAll, getNumericalCharacteristics, getXMLTag, isTrained, setNewAlphabetContainerInstance, toXML, train, train |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractScoreBasedClassifier(AlphabetContainer abc,
int classes)
0.
abc - the alphabets that are usedclasses - the number of different classes
public AbstractScoreBasedClassifier(AlphabetContainer abc,
int classes,
double classWeight)
classWeight.
abc - the alphabets that are usedclasses - the number of different classesclassWeight - the value of all class weights
public AbstractScoreBasedClassifier(AlphabetContainer abc,
int length,
int classes)
0.
abc - the alphabets that are usedlength - the length of the sequences that can be classifiedclasses - the number of different classes
IllegalArgumentException - if the length and the possible length of the
AlphabetContainer does not match
public AbstractScoreBasedClassifier(AlphabetContainer abc,
int length,
int classes,
double classWeight)
classWeight.
abc - the alphabets that are usedlength - the length of the sequences that can be classifiedclasses - the number of different classesclassWeight - the value of all class weights
IllegalArgumentException - if the length and the possible length of the
AlphabetContainer does not match
public AbstractScoreBasedClassifier(StringBuffer xml)
throws NonParsableException
Storable interface.
xml - the StringBuffer
NonParsableException - if the StringBuffer is not parsable| Method Detail |
|---|
public AbstractScoreBasedClassifier clone()
throws CloneNotSupportedException
clone in class AbstractClassifierCloneNotSupportedException
public byte classify(Sequence seq)
throws Exception
AbstractClassifieri,
with 0 < i < getNumberOfClasses(), of the class to
which the sequence is assigned.
classify in class AbstractClassifierseq - the sequence to be classified
Exception - if the classifier is not trained or something is wrong with
the sequence
protected LinkedList<? extends Result> getResults(Sample[] s,
MeasureParameters params,
boolean exceptionIfNotComputeable,
boolean all)
throws Exception
AbstractClassifier
getResults in class AbstractClassifiers - 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 wrongAbstractClassifier.evaluate(MeasureParameters, boolean, Sample...),
AbstractClassifier.evaluateAll(MeasureParameters, boolean,
Sample...)public double[] getClassWeights()
AbstractScoreBasedClassifier.
public int getNumberOfClasses()
AbstractClassifier
getNumberOfClasses in class AbstractClassifier
public double getScore(Sequence seq,
int i)
throws Exception
seq - the sequencei - the index of the class
Exception - if something went wrong
public final void setClassWeights(boolean add,
double... weights)
throws ClassDimensionException
sum_j=0_to_n exp(classWeight_j)=1: class weights may be
interpreted as logarithmic class-a-priori-probabilities.
add - if true the class weights are added to the
current class weightsweights - the array of weights, for each class the weight that is added
in a classification
ClassDimensionException - if something is wrong with the number of classes
public final void setThresholdClassWeights(boolean add,
double t)
throws OperationNotSupportedException
AbstractScoreBasedClassifier distinguishes
between 2 classes 0 and 1. In this case, t will be
interpreted as log(P(class1)/P(class(0))). A large
t (greater than 0) makes the classifier to decide more often
for class 1. A small
t (smaller than 0) makes the classifier to decide more often for class 0.
- Parameters:
add - if true the class weights are added to the
current class weightst - the new threshold
- Throws:
OperationNotSupportedException - if the classifier is no 2-class-classifier
public ConfusionMatrix test(Sample... testData)
throws Exception
AbstractClassifier
test in class AbstractClassifiertestData - the given array of test data
ClassDimensionException - if the number of samples in incorrect
Exception - if something went wrongprotected StringBuffer getFurtherClassifierInfos()
AbstractClassifierStringBuffer. This method is used by the method AbstractClassifier.toXML()
and should not be made public.
getFurtherClassifierInfos in class AbstractClassifierStringBuffer
protected void check(Sample s)
throws NotTrainedException,
IllegalArgumentException
Sample can be used.
s - the Sample to be checked
NotTrainedException - if the classifier is not trained
IllegalArgumentException - if something is wrong with sAbstractClassifier.setNewAlphabetContainerInstance(AlphabetContainer)
protected void check(Sequence seq)
throws NotTrainedException,
IllegalArgumentException
seq - the sequence to be checked
NotTrainedException - if the classifier is not trained
IllegalArgumentException - if something is wrong with seq
protected byte classify(Sequence seq,
boolean check)
throws Exception
alphabets, length,
isTrained()).
seq - the sequencecheck - if true the constraints will be checked
Exception - if something went wrongcheck(Sequence)
protected void createDefaultClassWeights(int classes,
double val)
throws IllegalArgumentException
val, so the class weights do not have any influence on
the classification.
classes - the number of different classesval - the value that is used for all classes
IllegalArgumentException - if the number of classes is below 2
protected void extractFurtherClassifierInfosFromXML(StringBuffer xml)
throws NonParsableException
AbstractClassifierAbstractClassifier.fromXML(StringBuffer) and
should not be made public.
extractFurtherClassifierInfosFromXML in class AbstractClassifierxml - XML representation
NonParsableException - if the information could not be parsed out of the
StringBufferprotected double getClassWeight(int index)
index.
index - the index of the class
protected abstract double getScore(Sequence seq,
int i,
boolean check)
throws IllegalArgumentException,
NotTrainedException,
Exception
seq - the sequencei - the index of the classcheck - the switch to decide whether to check
AlphabetContainer and length of the sequence or not
NotTrainedException - if the classifier is not trained
IllegalArgumentException - if something is wrong with seq
Exception - if something went wrong
public double[] getScores(Sample s)
throws Exception
s - the sample
Exception - if something went wrong
public double getPValue(Sequence candidate,
Sample bg)
throws Exception
candidate with respect to
a given background sample.
candidate.
for-loop. In
such cases one should use the method that works on two samples.
candidate - the candidate sequencebg - the background sample
candidate
Exception - if something went wronggetPValue(Sample, Sample)
public double[] getPValue(Sample candidates,
Sample bg)
throws Exception
candidates with
respect to a given background sample.
candidates - the candidate sequencesbg - the background sample
candidates
Exception - if something went wrong
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||