public abstract class ScoreClassifier extends AbstractScoreBasedClassifier
DifferentiableSequenceScore based classifier.AbstractScoreBasedClassifier.DoubleTableResult| Modifier and Type | Field and Description |
|---|---|
protected boolean |
hasBeenOptimized
This boolean indicates whether the classifier has been optimized with the
method
AbstractClassifier.train(DataSet[]) or
the weighted version. |
static double |
NOT_TRAINED_VALUE
This value should be used in
getLastScore() if the classifier is not trained. |
protected ScoreClassifierParameterSet |
params
The parameter set for the classifier.
|
protected DifferentiableSequenceScore[] |
score
The internally used scoring functions.
|
protected SafeOutputStream |
sostream
This stream is used for comments, e.g.
|
protected History |
template
The default history
|
| Constructor and Description |
|---|
ScoreClassifier(ScoreClassifierParameterSet params,
double lastScore,
DifferentiableSequenceScore... score)
Creates a new
ScoreClassifier from a given
ScoreClassifierParameterSet and DifferentiableSequenceScores . |
ScoreClassifier(StringBuffer xml)
The standard constructor for the interface
Storable. |
| Modifier and Type | Method and Description |
|---|---|
ScoreClassifier |
clone() |
protected void |
createStructure(DataSet[] data,
double[][] weights)
Creates the structure that will be used in the optimization.
|
protected void |
createStructure(DataSet[] data,
double[][] weights,
boolean initRandomly)
Creates the structure that will be used in the optimization.
|
protected double |
doOptimization(DataSet[] 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
AbstractClassifier.getNumberOfClasses() that contains information about the
classifier and for each class.
res[0] = new CategoricalResult( "classifier", "the kind of classifier", getInstanceName() ); |
ScoreClassifierParameterSet |
getCurrentParameterSet()
This method returns the current
ParameterSet of the classifier. |
DifferentiableSequenceScore |
getDifferentiableSequenceScore(int i)
Returns the internally used
DifferentiableSequenceScore with index
i. |
DifferentiableSequenceScore[] |
getDifferentiableSequenceScores()
Returns all internally used
DifferentiableSequenceScores in the internal
order. |
protected abstract DiffSSBasedOptimizableFunction |
getFunction(DataSet[] data,
double[][] weights)
Returns the function that 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.
|
protected int |
getIterations()
Returns the number of independent re-starts in the training.
|
double |
getLastScore()
Returns the score that was computed in the last optimization of the
parameters.
|
NumericalResultSet |
getNumericalCharacteristics()
Returns the subset of numerical values that are also returned by
AbstractClassifier.getCharacteristics(). |
protected double |
getScore(Sequence seq,
int i,
boolean check)
This method returns the score for a given
Sequence and a given
class. |
protected abstract String |
getXMLTag()
Returns the
String that is used as tag for the XML representation
of the classifier. |
boolean |
hasBeenOptimized()
This method indicates if the classifier has been optimized by a
train-method. |
void |
initUsingParameters(double[] parameters)
Sets the parameters of this classifier and the contained scoring functions
to the supplied parameters.
|
boolean |
isInitialized()
This method gives information about the state of the classifier.
|
protected OptimizableFunction.KindOfParameter |
preoptimize(OptimizableFunction f)
This method allows to pre-optimize the parameter before the real optimization.
|
void |
setOutputStream(OutputStream o)
Sets the
OutputStream that is used e.g. |
void |
train(DataSet[] data,
double[][] weights)
This method trains a classifier over an array of weighted
DataSet
s. |
check, check, classify, classify, createDefaultClassWeights, getClassWeight, getClassWeights, getMultiClassScores, getNumberOfClasses, getPValue, getPValue, getResults, getScore, getScores, setClassWeights, setClassWeights, setThresholdClassWeightsclassify, evaluate, evaluate, getAlphabetContainer, getCharacteristics, getLength, toXML, trainprotected DifferentiableSequenceScore[] score
protected ScoreClassifierParameterSet params
protected boolean hasBeenOptimized
AbstractClassifier.train(DataSet[]) or
the weighted version.protected SafeOutputStream sostream
public static final double NOT_TRAINED_VALUE
getLastScore() if the classifier is not trained.protected History template
public ScoreClassifier(ScoreClassifierParameterSet params, double lastScore, DifferentiableSequenceScore... score) throws CloneNotSupportedException
ScoreClassifier from a given
ScoreClassifierParameterSet and DifferentiableSequenceScores .params - the parameter set for the classifierlastScore - the score of the last optimization, if no such value exists the
programmer should use NOT_TRAINED_VALUEscore - the DifferentiableSequenceScores for the classesCloneNotSupportedException - if at least one DifferentiableSequenceScore could not be clonedAbstractScoreBasedClassifier.AbstractScoreBasedClassifier(AlphabetContainer,
int, int)public ScoreClassifier(StringBuffer xml) throws NonParsableException
Storable.
Creates a new ScoreClassifier out of its XML representation.xml - the XML representation as StringBufferNonParsableException - if the ScoreClassifier could not be reconstructed out
of the XML representation (the StringBuffer could not
be parsed)AbstractScoreBasedClassifier.AbstractScoreBasedClassifier(StringBuffer),
Storablepublic ScoreClassifier clone() throws CloneNotSupportedException
clone in class AbstractScoreBasedClassifierCloneNotSupportedExceptionpublic String getInstanceName()
AbstractClassifiergetInstanceName in class AbstractClassifierpublic CategoricalResult[] getClassifierAnnotation()
AbstractClassifierResults of dimension
AbstractClassifier.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" );
...
getClassifierAnnotation in class AbstractClassifierResults that contains information about the
classifierpublic NumericalResultSet getNumericalCharacteristics() throws Exception
AbstractClassifierAbstractClassifier.getCharacteristics().getNumericalCharacteristics in class AbstractClassifierException - if some of the characteristics could not be definedpublic boolean isInitialized()
AbstractClassifierisInitialized in class AbstractClassifiertrue if the classifier is initialized and therefore able
to classify sequences, otherwise falsepublic boolean hasBeenOptimized()
train-method.true if the classifier has been optimized by a
train-method, false otherwisepublic void setOutputStream(OutputStream o)
OutputStream that is used e.g. for writing information
during training. It is possible to set o=null, then nothing
will be written.o - the OutputStreampublic void train(DataSet[] data, double[][] weights) throws Exception
AbstractClassifierDataSet
s. That is why the following has to be fulfilled:
s.length == weights.length
weights[i] == null || s[i].getNumberOfElements() == weights[i].length.
AbstractClassifier.train(DataSet...).
DataSets are defined over the
underlying alphabet and length.train in class AbstractClassifierdata - an array of DataSetsweights - the weights for the DataSetsException - if the weights are incorrect or the training did not succeedAbstractClassifier.train(DataSet...)protected int getIterations()
AbstractDifferentiableSequenceScore.getNumberOfStarts(DifferentiableSequenceScore[])
for the internal DifferentiableSequenceScores.doOptimization(DataSet[], double[][]),
AbstractClassifier.train(DataSet...),
train(DataSet[], double[][])protected double doOptimization(DataSet[] reduced, double[][] newWeights) throws Exception
train-methodreduced - the data setsnewWeights - the weightsException - if something went wrong during the optimizationprotected OptimizableFunction.KindOfParameter preoptimize(OptimizableFunction f) throws Exception
f - the function to be optimizedException - if the pre-optimization failsprotected void createStructure(DataSet[] data, double[][] weights, boolean initRandomly) throws Exception
data - the dataweights - the weights of the datainitRandomly - initialize the functions randomlyException - if something went wrongpublic void initUsingParameters(double[] parameters)
throws Exception
parameters - the new parametersException - if the parameters could not be setprotected void createStructure(DataSet[] data, double[][] weights) throws Exception
data - the dataweights - the weights of the data *Exception - if something went wrongprotected void extractFurtherClassifierInfosFromXML(StringBuffer xml) throws NonParsableException
AbstractClassifierAbstractClassifier.fromXML(StringBuffer) and
should not be made public.extractFurtherClassifierInfosFromXML in class AbstractScoreBasedClassifierxml - the XML representation as StringBufferNonParsableException - if the information could not be parsed out of the XML
representation (the StringBuffer could not be parsed)AbstractClassifier.fromXML(StringBuffer)protected abstract DiffSSBasedOptimizableFunction getFunction(DataSet[] data, double[][] weights) throws Exception
data - the data setsweights - the weights of the sequences of the data setsException - 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 AbstractScoreBasedClassifierStringBufferAbstractClassifier.toXML()protected double getScore(Sequence seq, int i, boolean check) throws IllegalArgumentException, NotTrainedException, Exception
AbstractScoreBasedClassifierSequence and a given
class.getScore in class AbstractScoreBasedClassifierseq - the Sequencei - the index of the classcheck - the switch to decide whether to check
AlphabetContainer and the length of the
Sequence or notSequence and a given classIllegalArgumentException - if something is wrong with the Sequence
seqNotTrainedException - if the classifier is not trainedException - if something went wrongpublic double getLastScore()
public DifferentiableSequenceScore getDifferentiableSequenceScore(int i) throws CloneNotSupportedException
DifferentiableSequenceScore with index
i.i - the internal index of the DifferentiableSequenceScoreDifferentiableSequenceScore with index
iCloneNotSupportedException - if the DifferentiableSequenceScore could not be clonedpublic DifferentiableSequenceScore[] getDifferentiableSequenceScores() throws CloneNotSupportedException
DifferentiableSequenceScores in the internal
order.DifferentiableSequenceScores in the internal
orderCloneNotSupportedException - if a DifferentiableSequenceScore could not be clonedprotected abstract String getXMLTag()
AbstractClassifierString that is used as tag for the XML representation
of the classifier. This method is used by the methods
AbstractClassifier.fromXML(StringBuffer) and AbstractClassifier.toXML().getXMLTag in class AbstractClassifierString that is used as tag for the XML representation
of the classifierpublic ScoreClassifierParameterSet getCurrentParameterSet() throws CloneNotSupportedException
ParameterSet of the classifier.ParameterSet of the classifier.CloneNotSupportedException - if the ParameterSet could not be cloned