|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.scoringFunctions.AbstractNormalizableScoringFunction
de.jstacs.scoringFunctions.AbstractVariableLengthScoringFunction
de.jstacs.scoringFunctions.homogeneous.HomogeneousScoringFunction
de.jstacs.scoringFunctions.homogeneous.UniformHomogeneousScoringFunction
public class UniformHomogeneousScoringFunction
This scoring function does nothing. So it is possible to save parameters in an optimization.
Field Summary |
---|
Fields inherited from class de.jstacs.scoringFunctions.AbstractNormalizableScoringFunction |
---|
alphabets, length, r |
Fields inherited from interface de.jstacs.scoringFunctions.ScoringFunction |
---|
UNKNOWN |
Constructor Summary | |
---|---|
UniformHomogeneousScoringFunction(AlphabetContainer alphabets,
double ess)
This is the main constructor that creates an instance of a UniformHomogeneousScoringFunction that models each sequence
uniformly. |
|
UniformHomogeneousScoringFunction(StringBuffer xml)
This is the constructor for Storable . |
Method Summary | |
---|---|
void |
addGradientOfLogPriorTerm(double[] grad,
int start)
This method computes the gradient of NormalizableScoringFunction.getLogPriorTerm() for each
parameter of this model. |
protected void |
fromXML(StringBuffer xml)
This method is called in the constructor for the Storable
interface to create a scoring function from a StringBuffer . |
double[] |
getCurrentParameterValues()
Returns a double array of dimension
ScoringFunction.getNumberOfParameters() containing the current parameter values. |
double |
getEss()
Returns the equivalent sample size (ess) of this model, i.e. the equivalent sample size for the class or component that is represented by this model. |
String |
getInstanceName()
Returns a short instance name. |
double |
getLogNormalizationConstant(int length)
This method returns the logarithm of the normalization constant for a given sequence length. |
double |
getLogPartialNormalizationConstant(int parameterIndex,
int length)
This method returns the logarithm of the partial normalization constant for a given parameter index and a sequence length. |
double |
getLogPriorTerm()
This method computes a value that is proportional to
where prior is the prior for the parameters of this model. |
double |
getLogScore(Sequence seq,
int start,
int length)
This method computes the logarithm of the score for a given subsequence. |
double |
getLogScoreAndPartialDerivation(Sequence seq,
int start,
int length,
IntList indices,
DoubleList dList)
This method computes the logarithm of the score and the partial derivations for a given subsequence. |
int |
getMaximalMarkovOrder()
Returns the maximal used markov oder. |
int |
getNumberOfParameters()
Returns the number of parameters in this ScoringFunction . |
int |
getSizeOfEventSpaceForRandomVariablesOfParameter(int index)
Returns the size of the event space of the random variables that are affected by parameter no. |
void |
initializeFunction(int index,
boolean meila,
Sample[] data,
double[][] weights)
This method creates the underlying structure of the ScoringFunction . |
void |
initializeFunctionRandomly(boolean freeParams)
This method initializes the ScoringFunction randomly. |
void |
initializeUniformly(boolean freeParams)
This method allows to initialize the instance with an uniform distribution. |
boolean |
isInitialized()
This method can be used to determine whether the model is initialized. |
boolean |
isNormalized()
This method indicates whether the implemented score is already normalized to 1 or not. |
void |
setParameters(double[] params,
int start)
This method sets the internal parameters to the values of params between start and
start + |
void |
setStatisticForHyperparameters(int[] length,
double[] weights)
This method sets the hyperparameters for the model parameters by evaluating the given statistic. |
String |
toString()
|
StringBuffer |
toXML()
This method returns an XML representation as StringBuffer of an
instance of the implementing class. |
Methods inherited from class de.jstacs.scoringFunctions.AbstractVariableLengthScoringFunction |
---|
getLogNormalizationConstant, getLogPartialNormalizationConstant, getLogScore, getLogScoreAndPartialDerivation |
Methods inherited from class de.jstacs.scoringFunctions.AbstractNormalizableScoringFunction |
---|
clone, getAlphabetContainer, getInitialClassParam, getLength, getLogScore, getLogScoreAndPartialDerivation, getNumberOfRecommendedStarts, getNumberOfStarts, isNormalized |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface de.jstacs.scoringFunctions.NormalizableScoringFunction |
---|
getInitialClassParam |
Methods inherited from interface de.jstacs.scoringFunctions.ScoringFunction |
---|
clone, getAlphabetContainer, getLength, getLogScore, getLogScoreAndPartialDerivation, getNumberOfRecommendedStarts |
Constructor Detail |
---|
public UniformHomogeneousScoringFunction(AlphabetContainer alphabets, double ess)
UniformHomogeneousScoringFunction
that models each sequence
uniformly.
alphabets
- the AlphabetContainer
ess
- the equivalent sample size (ess) for the classpublic UniformHomogeneousScoringFunction(StringBuffer xml) throws NonParsableException
Storable
. Creates a new
UniformHomogeneousScoringFunction
out of its XML representation
as returned by fromXML(StringBuffer)
.
xml
- the XML representation as StringBuffer
NonParsableException
- if the XML representation could not be parsedMethod Detail |
---|
public String getInstanceName()
ScoringFunction
public double getLogScore(Sequence seq, int start, int length)
VariableLengthScoringFunction
seq
- the Sequence
start
- the start index in the Sequence
length
- the length of the Sequence
beginning at start
ScoringFunction.getLogScore(Sequence,
int)
public double getLogScoreAndPartialDerivation(Sequence seq, int start, int length, IntList indices, DoubleList dList)
VariableLengthScoringFunction
seq
- the Sequence
start
- the start index in the Sequence
length
- the end index in the Sequence
indices
- an IntList
of indices, after method invocation the
list should contain the indices i where
dList
- a DoubleList
of partial derivations, after method
invocation the list should contain the corresponding
ScoringFunction.getLogScoreAndPartialDerivation(Sequence, int,
IntList, DoubleList)
public int getNumberOfParameters()
ScoringFunction
ScoringFunction
. If the
number of parameters is not known yet, the method returns
ScoringFunction.UNKNOWN
.
ScoringFunction
ScoringFunction.UNKNOWN
public void setParameters(double[] params, int start)
ScoringFunction
params
between start
and
start + ScoringFunction.getNumberOfParameters()
- 1
params
- the new parametersstart
- the start index in params
public StringBuffer toXML()
Storable
StringBuffer
of an
instance of the implementing class.
public double getLogNormalizationConstant(int length)
VariableLengthScoringFunction
length
- the sequence length
NormalizableScoringFunction.getLogNormalizationConstant()
public void initializeFunction(int index, boolean meila, Sample[] data, double[][] weights)
ScoringFunction
ScoringFunction
.
index
- the index of the class the ScoringFunction
modelsmeila
- indicates whether the (reduced) parameterization is useddata
- the samplesweights
- the weights of the sequences in the samplesprotected void fromXML(StringBuffer xml) throws NonParsableException
AbstractNormalizableScoringFunction
Storable
interface to create a scoring function from a StringBuffer
.
fromXML
in class AbstractNormalizableScoringFunction
xml
- the XML representation as StringBuffer
NonParsableException
- if the StringBuffer
could not be parsedAbstractNormalizableScoringFunction.AbstractNormalizableScoringFunction(StringBuffer)
public int getSizeOfEventSpaceForRandomVariablesOfParameter(int index)
NormalizableScoringFunction
index
, i.e. the product of the
sizes of the alphabets at the position of each random variable affected
by parameter index
. For DNA alphabets this corresponds to 4
for a PWM, 16 for a WAM except position 0, ...
index
- the index of the parameter
public double getLogPartialNormalizationConstant(int parameterIndex, int length) throws Exception
VariableLengthScoringFunction
parameterIndex
- the index of the parameterlength
- the sequence length
Exception
- if something went wrongNormalizableScoringFunction.getLogPartialNormalizationConstant(int)
public double getEss()
NormalizableScoringFunction
public String toString()
toString
in class Object
public double getLogPriorTerm()
NormalizableScoringFunction
NormalizableScoringFunction.getEss()
* NormalizableScoringFunction.getLogNormalizationConstant()
+ Math.log( prior )
prior
is the prior for the parameters of this model.
NormalizableScoringFunction.getEss()
* NormalizableScoringFunction.getLogNormalizationConstant()
+ Math.log( prior ).
NormalizableScoringFunction.getEss()
,
NormalizableScoringFunction.getLogNormalizationConstant()
public void addGradientOfLogPriorTerm(double[] grad, int start)
NormalizableScoringFunction
NormalizableScoringFunction.getLogPriorTerm()
for each
parameter of this model. The results are added to the array
grad
beginning at index start
.
grad
- the array of gradientsstart
- the start index in the grad
array, where the
partial derivations for the parameters of this models shall be
enteredNormalizableScoringFunction.getLogPriorTerm()
public double[] getCurrentParameterValues() throws Exception
ScoringFunction
double
array of dimension
ScoringFunction.getNumberOfParameters()
containing the current parameter values.
If one likes to use these parameters to start an optimization it is
highly recommended to invoke
ScoringFunction.initializeFunction(int, boolean, Sample[], double[][])
before.
After an optimization this method can be used to get the current
parameter values.
Exception
- if no parameters exist (yet)public boolean isInitialized()
ScoringFunction
ScoringFunction.initializeFunction(int, boolean, Sample[], double[][])
.
true
if the model is initialized, false
otherwisepublic boolean isNormalized()
NormalizableScoringFunction
false
.
isNormalized
in interface NormalizableScoringFunction
isNormalized
in class AbstractNormalizableScoringFunction
true
if the implemented score is already normalized
to 1, false
otherwisepublic int getMaximalMarkovOrder()
HomogeneousScoringFunction
getMaximalMarkovOrder
in class HomogeneousScoringFunction
public void initializeFunctionRandomly(boolean freeParams) throws Exception
ScoringFunction
ScoringFunction
randomly. It has to
create the underlying structure of the ScoringFunction
.
freeParams
- indicates whether the (reduced) parameterization is used
Exception
- if something went wrongpublic void setStatisticForHyperparameters(int[] length, double[] weights) throws Exception
VariableLengthScoringFunction
length
) and how often (
weight
) they have been seen.
length
- the non-negative lengths of the sequencesweights
- the non-negative weight for the corresponding sequence
Exception
- if something went wrongMutable
public void initializeUniformly(boolean freeParams)
HomogeneousScoringFunction
initializeUniformly
in class HomogeneousScoringFunction
freeParams
- a switch whether to take only free parameters or to take all
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |