|
||||||||||
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.scoringFunctionBased.ScoreClassifier
public abstract class ScoreClassifier
Nested Class Summary |
---|
Nested classes/interfaces inherited from class de.jstacs.classifier.AbstractScoreBasedClassifier |
---|
AbstractScoreBasedClassifier.DoubleTableResult |
Field Summary | |
---|---|
protected boolean |
hasBeenOptimized
This boolean indicates whether the classifier has been optimized with the method AbstractClassifier.train(Sample...) or the weighted version. |
protected ScoreClassifierParameterSet |
params
The parameter set for the classifier. |
protected ScoringFunction[] |
score
The internally used scoring functions. |
protected SafeOutputStream |
sostream
This stream is used for comments, ... while the training, ... . |
Constructor Summary | |
---|---|
ScoreClassifier(ScoreClassifierParameterSet params,
ScoringFunction... score)
The default constructor. |
|
ScoreClassifier(StringBuffer xml)
This is the constructor for Storable . |
Method Summary | |
---|---|
ScoreClassifier |
clone()
|
protected void |
createStructure(Sample[] data,
double[][] weights)
Creates the structure that will be used in the optimization. |
protected double |
doOptimization(Sample[] reduced,
double[][] newWeights)
This method does the optimization of the train-method |
protected void |
extractFurtherClassifierInfosFromXML(StringBuffer xml)
Extracts further information of a classifier from an xml-representation. |
CategoricalResult[] |
getClassifierAnnotation()
Returns an array of Results of dimension getNumberOfClasses that contains information the
classifier and for each class. |
protected abstract OptimizableFunction |
getFunction(Sample[] data,
double[][] weights)
Returns the function the should be optimized |
protected StringBuffer |
getFurtherClassifierInfos()
This method returns further information of a classifier as a StringBuffer. |
String |
getInstanceName()
Returns a short description of the classifier. |
double |
getLastScore()
Return score that was computed in the last optimization of the parameters. |
NumericalResultSet |
getNumericalCharacteristics()
Returns the subset of numerical values that are also returned by getCharacteristsics . |
protected double |
getScore(Sequence seq,
int i,
boolean check)
This method returns the score for a given sequence and a given class. |
ScoringFunction |
getScoringFunction(int i)
Returns the internally used ScoringFunction with index i . |
ScoringFunction[] |
getScoringFunctions()
Returns all internally used ScoringFunctions in the internal order. |
protected abstract String |
getXMLTag()
Returns the String that is used as tag for the xml-representation. |
boolean |
hasBeenOptimized()
This method returns true if the classifier has been optimized by a train-method. |
boolean |
isTrained()
This method the state of the classifier. |
void |
setOutputStream(OutputStream o)
Sets the OutputStream that is used e.g. for writing information while training. |
void |
train(Sample[] data,
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, getScores, setClassWeights, setThresholdClassWeights, test |
Methods inherited from class de.jstacs.classifier.AbstractClassifier |
---|
classify, evaluate, evaluateAll, getAlphabetContainer, getCharacteristics, getClassificationRate, getLength, getMeasuresForEvaluate, getMeasuresForEvaluateAll, setNewAlphabetContainerInstance, toXML, train |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ScoringFunction[] score
protected ScoreClassifierParameterSet params
protected boolean hasBeenOptimized
AbstractClassifier.train(Sample...)
or the weighted version.
protected SafeOutputStream sostream
Constructor Detail |
---|
public ScoreClassifier(ScoreClassifierParameterSet params, ScoringFunction... score) throws CloneNotSupportedException
params
- the parameter set for the classifierscore
- the ScoringFunctions for the classes
CloneNotSupportedException
- if at least one ScoringFunction could not be clonedpublic ScoreClassifier(StringBuffer xml) throws NonParsableException
Storable
.
xml
- the xml representation
NonParsableException
- if the representation could not be parsed.Method Detail |
---|
public ScoreClassifier clone() throws CloneNotSupportedException
clone
in class AbstractScoreBasedClassifier
CloneNotSupportedException
public String getInstanceName()
AbstractClassifier
getInstanceName
in class AbstractClassifier
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
public 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 boolean hasBeenOptimized()
true
if the classifier has been optimized by a train-method.
true
if the classifier has been optimized by a train-methodpublic void setOutputStream(OutputStream o)
o=null
, than nothing will be written.
o
- the OutputStreampublic void train(Sample[] data, 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
data
- 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 double doOptimization(Sample[] reduced, double[][] newWeights) throws Exception
reduced
- the samplesnewWeights
- the weights
Exception
- if something went wrong while the optimizationprotected void createStructure(Sample[] data, double[][] weights) throws Exception
data
- the dataweights
- the weights of the data
Exception
- if something went wrongprotected void extractFurtherClassifierInfosFromXML(StringBuffer xml) throws NonParsableException
AbstractClassifier
fromXML( StringBuffer )
and should not be made public.
extractFurtherClassifierInfosFromXML
in class AbstractScoreBasedClassifier
xml
- the xml-representation
NonParsableException
protected abstract OptimizableFunction getFunction(Sample[] data, double[][] weights) throws Exception
data
- the samplesweights
- the weights of the sequences of the samples
Exception
- if something went wrongprotected StringBuffer getFurtherClassifierInfos()
AbstractClassifier
toXML()
and should not be made public.
getFurtherClassifierInfos
in class AbstractScoreBasedClassifier
protected double getScore(Sequence seq, int i, boolean check) throws IllegalArgumentException, NotTrainedException, 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
IllegalArgumentException
NotTrainedException
Exception
public double getLastScore()
public ScoringFunction getScoringFunction(int i) throws CloneNotSupportedException
i
.
i
- the internal index of the ScoringFunction
i
.
CloneNotSupportedException
- if the ScoringFunction could not be clonedpublic ScoringFunction[] getScoringFunctions() throws CloneNotSupportedException
CloneNotSupportedException
- if a ScoringFunction could not be clonedprotected abstract String getXMLTag()
AbstractClassifier
fromXML( StringBuffer )
and toXML()
.
getXMLTag
in class AbstractClassifier
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |