|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.jstacs.sequenceScores.differentiable.AbstractDifferentiableSequenceScore
de.jstacs.sequenceScores.statisticalModels.differentiable.AbstractDifferentiableStatisticalModel
public abstract class AbstractDifferentiableStatisticalModel
This class is the main part of any ScoreClassifier. It implements
many methods of the interface DifferentiableStatisticalModel.
| Field Summary |
|---|
| Fields inherited from class de.jstacs.sequenceScores.differentiable.AbstractDifferentiableSequenceScore |
|---|
alphabets, length, r |
| Fields inherited from interface de.jstacs.sequenceScores.differentiable.DifferentiableSequenceScore |
|---|
UNKNOWN |
| Constructor Summary | |
|---|---|
AbstractDifferentiableStatisticalModel(AlphabetContainer alphabets,
int length)
The main constructor. |
|
AbstractDifferentiableStatisticalModel(StringBuffer xml)
This is the constructor for Storable. |
|
| Method Summary | |
|---|---|
AbstractDifferentiableStatisticalModel |
clone()
Creates a clone (deep copy) of the current DifferentiableSequenceScore
instance. |
DataSet |
emitDataSet(int numberOfSequences,
int... seqLength)
This method returns a DataSet object containing artificial
sequence(s). |
double |
getInitialClassParam(double classProb)
Returns the initial class parameter for the class this DifferentiableSequenceScore is responsible for, based on the class
probability classProb. |
double |
getLogProbFor(Sequence sequence)
Returns the logarithm of the probability of the given sequence given the model. |
double |
getLogProbFor(Sequence sequence,
int startpos)
Returns the logarithm of the probability of (a part of) the given sequence given the model. |
double |
getLogProbFor(Sequence sequence,
int startpos,
int endpos)
Returns the logarithm of the probability of (a part of) the given sequence given the model. |
double[] |
getLogScoreFor(DataSet data)
This method computes the logarithm of the scores of all sequences in the given sample. |
void |
getLogScoreFor(DataSet data,
double[] res)
This method computes and stores the logarithm of the scores for any sequence in the sample in the given double-array. |
byte |
getMaximalMarkovOrder()
This method returns the maximal used Markov order, if possible. |
boolean |
isNormalized()
This method indicates whether the implemented score is already normalized to 1 or not. |
static boolean |
isNormalized(DifferentiableSequenceScore... function)
This method checks whether all given DifferentiableStatisticalModels
are normalized. |
| Methods inherited from class de.jstacs.sequenceScores.differentiable.AbstractDifferentiableSequenceScore |
|---|
fromXML, getAlphabetContainer, getCharacteristics, getLength, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivation, getLogScoreFor, getLogScoreFor, getNumberOfRecommendedStarts, getNumberOfStarts, getNumericalCharacteristics |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface de.jstacs.sequenceScores.statisticalModels.differentiable.DifferentiableStatisticalModel |
|---|
addGradientOfLogPriorTerm, getESS, getLogNormalizationConstant, getLogPartialNormalizationConstant, getLogPriorTerm, getSizeOfEventSpaceForRandomVariablesOfParameter |
| Methods inherited from interface de.jstacs.sequenceScores.differentiable.DifferentiableSequenceScore |
|---|
getCurrentParameterValues, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivation, getNumberOfParameters, getNumberOfRecommendedStarts, initializeFunction, initializeFunctionRandomly, setParameters |
| Methods inherited from interface de.jstacs.sequenceScores.SequenceScore |
|---|
getAlphabetContainer, getCharacteristics, getInstanceName, getLength, getLogScoreFor, getLogScoreFor, getLogScoreFor, getNumericalCharacteristics, isInitialized |
| Methods inherited from interface de.jstacs.Storable |
|---|
toXML |
| Constructor Detail |
|---|
public AbstractDifferentiableStatisticalModel(AlphabetContainer alphabets,
int length)
throws IllegalArgumentException
alphabets - the AlphabetContainer of this DifferentiableSequenceScorelength - the length of this DifferentiableSequenceScore, i.e. the length of
the modeled sequences
IllegalArgumentException - if the length is negative or does not match with AlphabetContainer.getPossibleLength()public AbstractDifferentiableStatisticalModel(StringBuffer xml)
throws NonParsableException
Storable. Creates a new
AbstractDifferentiableStatisticalModel out of a StringBuffer
.
xml - the XML representation as StringBuffer
NonParsableException - if the XML representation could not be parsed| Method Detail |
|---|
public AbstractDifferentiableStatisticalModel clone()
throws CloneNotSupportedException
DifferentiableSequenceScoreDifferentiableSequenceScore
instance.
clone in interface DifferentiableSequenceScoreclone in interface SequenceScoreclone in class AbstractDifferentiableSequenceScoreDifferentiableSequenceScore
CloneNotSupportedException - if something went wrong while cloning the
DifferentiableSequenceScorepublic boolean isNormalized()
DifferentiableStatisticalModelfalse.
isNormalized in interface DifferentiableStatisticalModeltrue if the implemented score is already normalized
to 1, false otherwisepublic static boolean isNormalized(DifferentiableSequenceScore... function)
DifferentiableStatisticalModels
are normalized.
function - the DifferentiableStatisticalModels to be checked
true if all DifferentiableStatisticalModels are
already normalized, otherwise falseDifferentiableStatisticalModel.isNormalized()public double getInitialClassParam(double classProb)
DifferentiableSequenceScoreDifferentiableSequenceScore is responsible for, based on the class
probability classProb.
getInitialClassParam in interface DifferentiableSequenceScoregetInitialClassParam in class AbstractDifferentiableSequenceScoreclassProb - the class probability
public double getLogProbFor(Sequence sequence)
StatisticalModellength and the alphabets define the type of
data that can be modeled and therefore both has to be checked.
getLogProbFor in interface StatisticalModelsequence - the given sequence for which the logarithm of the
probability/the value of the density function should be
returned
StatisticalModel.getLogProbFor(Sequence, int, int)public double getLogProbFor(Sequence sequence,
int startpos)
throws Exception
StatisticalModelstartpos. E.g. the fixed length is 12. The length
of the given sequence is 30 and the startpos=15 the logarithm
of the probability of the part from position 15 to 26 (inclusive) given
the model should be returned.
length and the alphabets define the type of
data that can be modeled and therefore both has to be checked.
getLogProbFor in interface StatisticalModelsequence - the given sequencestartpos - the start position within the given sequence
Exception - if the sequence could not be handled by the model
NotTrainedException - if the model is not trained yetStatisticalModel.getLogProbFor(Sequence, int, int)public double getLogProbFor(Sequence sequence,
int startpos,
int endpos)
StatisticalModelStatisticalModel.getLogProbFor(Sequence, int) by the fact, that the model could be
e.g. homogeneous and therefore the length of the sequences, whose
probability should be returned, is not fixed. Additionally, the end
position of the part of the given sequence is given and the probability
of the part from position startpos to endpos
(inclusive) should be returned.
length and the alphabets define the type of
data that can be modeled and therefore both has to be checked.
getLogProbFor in interface StatisticalModelsequence - the given sequencestartpos - the start position within the given sequenceendpos - the last position to be taken into account
public double[] getLogScoreFor(DataSet data)
throws Exception
SequenceScoreSequenceScore.getLogScoreFor(Sequence).
getLogScoreFor in interface SequenceScoregetLogScoreFor in class AbstractDifferentiableSequenceScoredata - the sample of sequences
Exception - if something went wrongSequenceScore.getLogScoreFor(Sequence)public void getLogScoreFor(DataSet data,
double[] res)
throws Exception
SequenceScoredouble-array.
SequenceScore.getLogScoreFor(Sequence).
getLogScoreFor in interface SequenceScoregetLogScoreFor in class AbstractDifferentiableSequenceScoredata - the sample of sequencesres - the array for the results, has to have length
data.getNumberOfElements() (which returns the
number of sequences in the sample)
Exception - if something went wrongSequenceScore.getLogScoreFor(Sequence),
SequenceScore.getLogScoreFor(DataSet)public DataSet emitDataSet(int numberOfSequences,
int... seqLength)
throws NotTrainedException,
Exception
StatisticalModelDataSet object containing artificial
sequence(s).
emitDataSet( int n, int l ) should return a data set with
n sequences of length l.
emitDataSet( int n, int[] l ) should return a data set with
n sequences which have a sequence length corresponding to
the entry in the given array l.
emitDataSet( int n ) and
emitDataSet( int n, null ) should return a sample with
n sequences of length of the model (
SequenceScore.getLength()).
Exception.
emitDataSet in interface StatisticalModelnumberOfSequences - the number of sequences that should be contained in the
returned sampleseqLength - the length of the sequences for a homogeneous model; for an
inhomogeneous model this parameter should be null
or an array of size 0.
DataSet containing the artificial sequence(s)
NotTrainedException - if the model is not trained yet
Exception - if the emission did not succeedDataSetpublic byte getMaximalMarkovOrder()
throws UnsupportedOperationException
StatisticalModel
getMaximalMarkovOrder in interface StatisticalModelUnsupportedOperationException - if the model can't give a proper answer
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||