|
||||||||||
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 DifferentiableStatisticalModel s
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 DifferentiableSequenceScore
length
- 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 parsedMethod Detail |
---|
public AbstractDifferentiableStatisticalModel clone() throws CloneNotSupportedException
DifferentiableSequenceScore
DifferentiableSequenceScore
instance.
clone
in interface DifferentiableSequenceScore
clone
in interface SequenceScore
clone
in class AbstractDifferentiableSequenceScore
DifferentiableSequenceScore
CloneNotSupportedException
- if something went wrong while cloning the
DifferentiableSequenceScore
public boolean isNormalized()
DifferentiableStatisticalModel
false
.
isNormalized
in interface DifferentiableStatisticalModel
true
if the implemented score is already normalized
to 1, false
otherwisepublic static boolean isNormalized(DifferentiableSequenceScore... function)
DifferentiableStatisticalModel
s
are normalized.
function
- the DifferentiableStatisticalModel
s to be checked
true
if all DifferentiableStatisticalModel
s are
already normalized, otherwise false
DifferentiableStatisticalModel.isNormalized()
public double getInitialClassParam(double classProb)
DifferentiableSequenceScore
DifferentiableSequenceScore
is responsible for, based on the class
probability classProb
.
getInitialClassParam
in interface DifferentiableSequenceScore
getInitialClassParam
in class AbstractDifferentiableSequenceScore
classProb
- the class probability
public double getLogProbFor(Sequence sequence)
StatisticalModel
length
and the alphabets
define the type of
data that can be modeled and therefore both has to be checked.
getLogProbFor
in interface StatisticalModel
sequence
- 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
StatisticalModel
startpos
. 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 StatisticalModel
sequence
- 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)
StatisticalModel
StatisticalModel.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 StatisticalModel
sequence
- 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
SequenceScore
SequenceScore.getLogScoreFor(Sequence)
.
getLogScoreFor
in interface SequenceScore
getLogScoreFor
in class AbstractDifferentiableSequenceScore
data
- the sample of sequences
Exception
- if something went wrongSequenceScore.getLogScoreFor(Sequence)
public void getLogScoreFor(DataSet data, double[] res) throws Exception
SequenceScore
double
-array.
SequenceScore.getLogScoreFor(Sequence)
.
getLogScoreFor
in interface SequenceScore
getLogScoreFor
in class AbstractDifferentiableSequenceScore
data
- 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
StatisticalModel
DataSet
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 StatisticalModel
numberOfSequences
- 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 succeedDataSet
public byte getMaximalMarkovOrder() throws UnsupportedOperationException
StatisticalModel
getMaximalMarkovOrder
in interface StatisticalModel
UnsupportedOperationException
- 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 |