|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.models.AbstractModel
de.jstacs.models.mixture.AbstractMixtureModel
de.jstacs.models.mixture.StrandModel
public class StrandModel
This model handles sequences that can either lie on the forward strand or on the backward strand. Therefore it is recommended to use this model only for DNA, but it is not restricted to DNA.
Model
Nested Class Summary |
---|
Nested classes/interfaces inherited from class de.jstacs.models.mixture.AbstractMixtureModel |
---|
AbstractMixtureModel.Algorithm, AbstractMixtureModel.Parameterization |
Field Summary |
---|
Fields inherited from class de.jstacs.models.mixture.AbstractMixtureModel |
---|
algorithm, algorithmHasBeenRun, alternativeModel, burnInTest, componentHyperParams, compProb, counter, dimension, estimateComponentProbs, file, filereader, filewriter, initialIteration, logWeights, model, optimizeModel, sample, samplingIndex, sostream, starts, stationaryIteration, weights |
Fields inherited from class de.jstacs.models.AbstractModel |
---|
alphabets, length |
Constructor Summary | |
---|---|
protected |
StrandModel(Model model,
int starts,
boolean estimateComponentProbs,
double[] componentHyperParams,
double forwardStrandProb,
AbstractMixtureModel.Algorithm algorithm,
double alpha,
double eps,
AbstractMixtureModel.Parameterization parametrization,
int initialIteration,
int stationaryIteration,
BurnInTest burnInTest)
Creates a new StrandModel. |
|
StrandModel(Model model,
int starts,
double[] componentHyperParams,
double alpha,
double eps,
AbstractMixtureModel.Parameterization parametrization)
Creates an instance using EM and estimating the component probabilities. |
|
StrandModel(Model model,
int starts,
double[] componentHyperParams,
int initialIteration,
int stationaryIteration,
BurnInTest burnInTest)
Creates an instance using Gibbs Sampling and sampling the component probabilities. |
|
StrandModel(Model model,
int starts,
double forwardStrandProb,
double alpha,
double eps,
AbstractMixtureModel.Parameterization parametrization)
Creates an instance using EM and fixed component probabilities. |
|
StrandModel(Model model,
int starts,
double forwardStrandProb,
int initialIteration,
int stationaryIteration,
BurnInTest burnInTest)
Creates an instance using Gibbs Sampling and fixed component probabilities. |
|
StrandModel(StringBuffer stringBuff)
This constructor can be used for loading a StrandModel form a StringBuffer ; |
Method Summary | |
---|---|
protected double[][] |
doFirstIteration(double[] dataWeights,
MultivariateRandomGenerator m,
MRGParams[] params)
This method will do the first step in the train algorithm for the current model on the internal sample. |
protected Sequence[] |
emitSampleUsingCurrentParameterSet(int n,
int... lengths)
The method returns an array of sequences using the current parameter set. |
protected double |
getLogProbUsingCurrentParameterSetFor(int component,
Sequence s,
int start,
int end)
Returns the log probability for the sequence and the given component using the current parameter set. |
protected double |
getNewWeights(double[] dataWeights,
double[] w,
double[][] seqweights)
Computes sequence weights and returns the score. |
void |
setTrainData(Sample s)
This method is invoked by the train method and set for a given sample the sample that should be used for train. |
String |
toString()
Should give a simple representation (text) of the model as String. |
Methods inherited from class de.jstacs.models.AbstractModel |
---|
getAlphabetContainer, getLength, getLogProbFor, getLogProbFor, getLogProbFor, getMaximalMarkovOrder, getPriorTerm, getProbFor, getProbFor, setNewAlphabetContainerInstance, train |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected StrandModel(Model model, int starts, boolean estimateComponentProbs, double[] componentHyperParams, double forwardStrandProb, AbstractMixtureModel.Algorithm algorithm, double alpha, double eps, AbstractMixtureModel.Parameterization parametrization, int initialIteration, int stationaryIteration, BurnInTest burnInTest) throws CloneNotSupportedException, IllegalArgumentException, WrongAlphabetException
model
- the model building the basis of the StrandModel, if the instance is trained using
AbstractMixtureModel.Algorithm.GIBBS_SAMPLING
the model has to implement
GibbsSamplingComponent
starts
- the number of times the algorithm will be started in the train method, at least 1estimateComponentProbs
- the switch for estimating the component probabilities in the algorithm or to hold them fixed;
if the component parameters are fixed, the value forwardStrandProb
will be used,
otherwise the componentHyperParams
will be incorporated in the adjustmentcomponentHyperParams
- the hyperparameters for the component assignment prior,
estimateComponentProbs == true
null
or has to have length 2
null
or an array with all values zero (0) than ML
parameterization
forwardStrandProb
- the probability for the forward strandalgorithm
- either AbstractMixtureModel.Algorithm.EM
or AbstractMixtureModel.Algorithm.GIBBS_SAMPLING
alpha
- only for AbstractMixtureModel.Algorithm.EM
train
to initialize
the gammas. It is recommended to use alpha = 1
(uniform distribution on a simplex).eps
- only for AbstractMixtureModel.Algorithm.EM
parametrization
- only for AbstractMixtureModel.Algorithm.EM
AbstractMixtureModel.Parameterization.THETA
or AbstractMixtureModel.Parameterization.LAMBDA
LAMBDA
initialIteration
- only for AbstractMixtureModel.Algorithm.GIBBS_SAMPLING
stationaryIteration/starts
)stationaryIteration
- only for AbstractMixtureModel.Algorithm.GIBBS_SAMPLING
burnInTest
- only for AbstractMixtureModel.Algorithm.GIBBS_SAMPLING
IllegalArgumentException
- if
length
dimension < 1
weights != null && weights.length != dimension
weights != null
and it exists an i
where weights[i] < 0
starts < 1
WrongAlphabetException
- if not all models
work on the same alphabet
CloneNotSupportedException
- if the models
can not be clonedpublic StrandModel(Model model, int starts, double[] componentHyperParams, double alpha, double eps, AbstractMixtureModel.Parameterization parametrization) throws CloneNotSupportedException, IllegalArgumentException, WrongAlphabetException
model
- the model building the basis of the StrandModel, if the instance is trained using
AbstractMixtureModel.Algorithm.GIBBS_SAMPLING
the model has to implement
GibbsSamplingComponent
starts
- the number of times the algorithm will be started in the train method, at least 1componentHyperParams
- the hyperparameters for the component assignment prior,
estimateComponentProbs == true
null
or has to have length 2
null
or an array with all values zero (0) than ML
parameterization
alpha
- only for AbstractMixtureModel.Algorithm.EM
train
to initialize
the gammas. It is recommended to use alpha = 1
(uniform distribution on a simplex).eps
- only for AbstractMixtureModel.Algorithm.EM
parametrization
- only for AbstractMixtureModel.Algorithm.EM
AbstractMixtureModel.Parameterization.THETA
or AbstractMixtureModel.Parameterization.LAMBDA
LAMBDA
IllegalArgumentException
- if
length
dimension < 1
weights != null && weights.length != dimension
weights != null
and it exists an i
where weights[i] < 0
starts < 1
WrongAlphabetException
- if not all models
work on the same alphabet
CloneNotSupportedException
- if the models
can not be clonedStrandModel( de.jstacs.models.Model, int, boolean, double[], double, de.jstacs.models.mixture.AbstractMixtureModel.Algorithm, double, double, de.jstacs.models.mixture.AbstractMixtureModel.Parameterization, int, int, de.jstacs.models.mixture.gibbssampling.BurnInTest )
,
AbstractMixtureModel.Algorithm.EM
public StrandModel(Model model, int starts, double forwardStrandProb, double alpha, double eps, AbstractMixtureModel.Parameterization parametrization) throws CloneNotSupportedException, IllegalArgumentException, WrongAlphabetException
model
- the model building the basis of the StrandModel, if the instance is trained using
AbstractMixtureModel.Algorithm.GIBBS_SAMPLING
the model has to implement
GibbsSamplingComponent
starts
- the number of times the algorithm will be started in the train method, at least 1forwardStrandProb
- the probability for the forward strandalpha
- only for AbstractMixtureModel.Algorithm.EM
train
to initialize
the gammas. It is recommended to use alpha = 1
(uniform distribution on a simplex).eps
- only for AbstractMixtureModel.Algorithm.EM
parametrization
- only for AbstractMixtureModel.Algorithm.EM
AbstractMixtureModel.Parameterization.THETA
or AbstractMixtureModel.Parameterization.LAMBDA
LAMBDA
IllegalArgumentException
- if
length
dimension < 1
weights != null && weights.length != dimension
weights != null
and it exists an i
where weights[i] < 0
starts < 1
WrongAlphabetException
- if not all models
work on the same alphabet
CloneNotSupportedException
- if the models
can not be clonedStrandModel( de.jstacs.models.Model, int, boolean, double[], double, de.jstacs.models.mixture.AbstractMixtureModel.Algorithm, double, double, de.jstacs.models.mixture.AbstractMixtureModel.Parameterization, int, int, de.jstacs.models.mixture.gibbssampling.BurnInTest )
,
AbstractMixtureModel.Algorithm.EM
public StrandModel(Model model, int starts, double[] componentHyperParams, int initialIteration, int stationaryIteration, BurnInTest burnInTest) throws CloneNotSupportedException, IllegalArgumentException, WrongAlphabetException
model
- the model building the basis of the StrandModel, if the instance is trained using
AbstractMixtureModel.Algorithm.GIBBS_SAMPLING
the model has to implement
GibbsSamplingComponent
starts
- the number of times the algorithm will be started in the train method, at least 1componentHyperParams
- the hyperparameters for the component assignment prior,
estimateComponentProbs == true
null
or has to have length 2
null
or an array with all values zero (0) than ML
parameterization
initialIteration
- only for AbstractMixtureModel.Algorithm.GIBBS_SAMPLING
stationaryIteration/starts
)stationaryIteration
- only for AbstractMixtureModel.Algorithm.GIBBS_SAMPLING
burnInTest
- only for AbstractMixtureModel.Algorithm.GIBBS_SAMPLING
IllegalArgumentException
- if
length
dimension < 1
weights != null && weights.length != dimension
weights != null
and it exists an i
where weights[i] < 0
starts < 1
WrongAlphabetException
- if not all models
work on the same alphabet
CloneNotSupportedException
- if the models
can not be clonedStrandModel( de.jstacs.models.Model, int, boolean, double[], double, de.jstacs.models.mixture.AbstractMixtureModel.Algorithm, double, double, de.jstacs.models.mixture.AbstractMixtureModel.Parameterization, int, int, de.jstacs.models.mixture.gibbssampling.BurnInTest )
,
AbstractMixtureModel.Algorithm.GIBBS_SAMPLING
public StrandModel(Model model, int starts, double forwardStrandProb, int initialIteration, int stationaryIteration, BurnInTest burnInTest) throws CloneNotSupportedException, IllegalArgumentException, WrongAlphabetException
model
- the model building the basis of the StrandModel, if the instance is trained using
AbstractMixtureModel.Algorithm.GIBBS_SAMPLING
the model has to implement
GibbsSamplingComponent
starts
- the number of times the algorithm will be started in the train method, at least 1forwardStrandProb
- the probability for the forward strandinitialIteration
- only for AbstractMixtureModel.Algorithm.GIBBS_SAMPLING
stationaryIteration/starts
)stationaryIteration
- only for AbstractMixtureModel.Algorithm.GIBBS_SAMPLING
burnInTest
- only for AbstractMixtureModel.Algorithm.GIBBS_SAMPLING
IllegalArgumentException
- if
length
dimension < 1
weights != null && weights.length != dimension
weights != null
and it exists an i
where weights[i] < 0
starts < 1
WrongAlphabetException
- if not all models
work on the same alphabet
CloneNotSupportedException
- if the models
can not be clonedStrandModel( de.jstacs.models.Model, int, boolean, double[], double, de.jstacs.models.mixture.AbstractMixtureModel.Algorithm, double, double, de.jstacs.models.mixture.AbstractMixtureModel.Parameterization, int, int, de.jstacs.models.mixture.gibbssampling.BurnInTest )
,
AbstractMixtureModel.Algorithm.GIBBS_SAMPLING
public StrandModel(StringBuffer stringBuff) throws NonParsableException
StrandModel
form a StringBuffer
;
stringBuff
- the StringBuffer
containing the xml representation of the model.
NonParsableException
- if the StringBuffer
could not be parsed.Method Detail |
---|
public void setTrainData(Sample s) throws Exception
AbstractMixtureModel
setTrainData
in class AbstractMixtureModel
s
- the given sample
Exception
protected double[][] doFirstIteration(double[] dataWeights, MultivariateRandomGenerator m, MRGParams[] params) throws Exception
AbstractMixtureModel
doFirstIteration
in class AbstractMixtureModel
dataWeights
- null
or the weights of each element of the samplem
- the multivariate random generatorparams
- the parameters for the multivariate random generator
Exception
- if something went wrongprotected double getNewWeights(double[] dataWeights, double[] w, double[][] seqweights) throws Exception
getNewWeights
in class AbstractMixtureModel
dataWeights
- the weights for internal sample (should not be changed)w
- the array for the statistic of the component parameters (shall
be filled)seqweights
- an array containing for each component the weights for each
sequence (shall be filled)
Exception
- if something went wrongpublic String toString()
Model
toString
in interface Model
toString
in class Object
protected Sequence[] emitSampleUsingCurrentParameterSet(int n, int... lengths) throws NotTrainedException, Exception
AbstractMixtureModel
emitSampleUsingCurrentParameterSet
in class AbstractMixtureModel
n
- the number of sequences to be sampledlengths
- the corresponding lengths
Exception
- if it was impossible to sample
NotTrainedException
AbstractModel.emitSample(int, int...)
protected double getLogProbUsingCurrentParameterSetFor(int component, Sequence s, int start, int end) throws Exception
AbstractMixtureModel
getLogProbUsingCurrentParameterSetFor
in class AbstractMixtureModel
component
- the index of the components
- the sequencestart
- the start position in the sequenceend
- the end position in the sequence
log P(s,component) = log P(s|component) + log P(component)
Exception
- if not trained yet or something else went wrongAbstractMixtureModel.getNumberOfComponents()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |