public class HomogeneousMM extends HomogeneousTrainSM
HomMMParameterSetHomogeneousTrainSM.HomCondProborder, powersparams, trainedalphabets, length| Constructor and Description |
|---|
HomogeneousMM(HomMMParameterSet params)
Creates a new homogeneous Markov model from a parameter set.
|
HomogeneousMM(StringBuffer stringBuff)
The standard constructor for the interface
Storable. |
| Modifier and Type | Method and Description |
|---|---|
HomogeneousMM |
clone()
Follows the conventions of
Object's clone()-method. |
protected StringBuffer |
getFurtherModelInfos()
Returns further model information as a
StringBuffer. |
String |
getInstanceName()
Should return a short instance name such as iMM(0), BN(2), ...
|
double |
getLogPriorTerm()
Returns a value that is proportional to the log of the prior.
|
protected Sequence |
getRandomSequence(Random r,
int length)
This method creates a random
Sequence from a trained homogeneous
model. |
protected String |
getXMLTag()
Returns the XML tag that is used for this model in
DiscreteGraphicalTrainSM.fromXML(StringBuffer) and DiscreteGraphicalTrainSM.toXML(). |
protected double |
logProbFor(Sequence sequence,
int startpos,
int endpos)
This method computes the logarithm of the probability of the given
Sequence in the given interval. |
protected void |
set(DGTrainSMParameterSet params,
boolean trained)
Sets the parameters as internal parameters and does some essential
computations.
|
protected void |
setFurtherModelInfos(StringBuffer xml)
This method replaces the internal model information with those from a
StringBuffer. |
String |
toString(NumberFormat nf)
This method returns a
String representation of the instance. |
void |
train(DataSet[] data,
double[][] weights)
Trains the homogeneous model using an array of weighted
DataSets. |
void |
train(DataSet data,
double[] weights)
Trains the
TrainableStatisticalModel object given the data as DataSet using
the specified weights. |
check, chooseFromDistr, cloneHomProb, emitDataSet, getLogProbFor, getMaximalMarkovOrder, getNumericalCharacteristics, trainfromXML, getCurrentParameterSet, getDescription, getESS, isInitialized, toXMLgetAlphabetContainer, getCharacteristics, getLength, getLogProbFor, getLogProbFor, getLogScoreFor, getLogScoreFor, getLogScoreFor, getLogScoreFor, getLogScoreFor, toString, trainpublic HomogeneousMM(HomMMParameterSet params) throws CloneNotSupportedException, IllegalArgumentException, NonParsableException
params - the parameter setCloneNotSupportedException - if the parameter set could not be clonedIllegalArgumentException - if the parameter set is not instantiatedNonParsableException - if the parameter set is not parsableHomMMParameterSet,
HomogeneousTrainSM.HomogeneousTrainSM(de.jstacs.sequenceScores.statisticalModels.trainable.discrete.homogeneous.parameters.HomogeneousTrainSMParameterSet)public HomogeneousMM(StringBuffer stringBuff) throws NonParsableException
Storable.
Creates a new HomogeneousMM out of its XML representation.stringBuff - the XML representation as StringBufferNonParsableException - if the HomogeneousMM could not be reconstructed out
of the XML representation (the StringBuffer could not
be parsed)Storablepublic HomogeneousMM clone() throws CloneNotSupportedException
AbstractTrainableStatisticalModelObject's clone()-method.clone in interface SequenceScoreclone in interface TrainableStatisticalModelclone in class DiscreteGraphicalTrainSMAbstractTrainableStatisticalModel
(the member-AlphabetContainer isn't deeply cloned since
it is assumed to be immutable). The type of the returned object
is defined by the class X directly inherited from
AbstractTrainableStatisticalModel. Hence X's
clone()-method should work as:Object o = (X)super.clone(); o defined by
X that are not of simple data-types like
int, double, ... have to be deeply
copied return oCloneNotSupportedException - if something went wrong while cloningprotected Sequence getRandomSequence(Random r, int length) throws WrongAlphabetException, WrongSequenceTypeException
HomogeneousTrainSMSequence from a trained homogeneous
model.getRandomSequence in class HomogeneousTrainSMr - the random generatorlength - the length of the SequenceSequenceWrongAlphabetException - if something is wrong with the alphabetWrongSequenceTypeException - if the Sequence type is not suitable (for the
AlphabetContainer)public String getInstanceName()
SequenceScorepublic double getLogPriorTerm()
throws Exception
StatisticalModelException - if something went wrongprotected double logProbFor(Sequence sequence, int startpos, int endpos)
HomogeneousTrainSMSequence in the given interval. The method is only used in
StatisticalModel.getLogProbFor(Sequence, int, int) after
the method HomogeneousTrainSM.check(Sequence, int, int) has been
invoked.logProbFor in class HomogeneousTrainSMsequence - the Sequencestartpos - the start position within the Sequenceendpos - the end position within the SequenceHomogeneousTrainSM.check(Sequence, int, int),
StatisticalModel.getLogProbFor(Sequence, int, int)public String toString(NumberFormat nf)
SequenceScoreString representation of the instance.toString in interface SequenceScoretoString in class DiscreteGraphicalTrainSMnf - the NumberFormat for the String representation of parameters or probabilitiesString representation of the instancepublic void train(DataSet data, double[] weights) throws Exception
TrainableStatisticalModelTrainableStatisticalModel object given the data as DataSet using
the specified weights. The weight at position i belongs to the element at
position i. So the array weight should have the number of
sequences in the data set as dimension. (Optionally it is possible to use
weight == null if all weights have the value one.)train(data1); train(data2)
should be a fully trained model over data2 and not over
data1+data2. All parameters of the model were given by the
call of the constructor.data - the given sequences as DataSetweights - the weights of the elements, each weight should be
non-negativeException - if the training did not succeed (e.g. the dimension of
weights and the number of sequences in the
data set do not match)DataSet.getElementAt(int),
DataSet.ElementEnumeratorpublic void train(DataSet[] data, double[][] weights) throws Exception
HomogeneousTrainSMDataSets.
The Sequence weights in weights[i] are for the
DataSet in data[i].train in class HomogeneousTrainSMdata - the given DataSetsweights - the weightsException - if something went wrong, furthermore data.length
has to be weights.lengthprotected StringBuffer getFurtherModelInfos()
DiscreteGraphicalTrainSMStringBuffer.getFurtherModelInfos in class DiscreteGraphicalTrainSMDiscreteGraphicalTrainSM.toXML()protected String getXMLTag()
DiscreteGraphicalTrainSMDiscreteGraphicalTrainSM.fromXML(StringBuffer) and DiscreteGraphicalTrainSM.toXML().getXMLTag in class DiscreteGraphicalTrainSMDiscreteGraphicalTrainSM.fromXML(StringBuffer) and
DiscreteGraphicalTrainSM.toXML()DiscreteGraphicalTrainSM.fromXML(StringBuffer),
DiscreteGraphicalTrainSM.toXML()protected void set(DGTrainSMParameterSet params, boolean trained) throws CloneNotSupportedException, NonParsableException
DiscreteGraphicalTrainSMfromParameterSet-methods.set in class HomogeneousTrainSMparams - the new ParameterSettrained - indicates if the model is trained or notCloneNotSupportedException - if the parameter set could not be clonedNonParsableException - if the parameters of the model could not be parsedprotected void setFurtherModelInfos(StringBuffer xml) throws NonParsableException
DiscreteGraphicalTrainSMStringBuffer.setFurtherModelInfos in class DiscreteGraphicalTrainSMxml - contains the model information like parameters of the
distribution etc. in XML formatNonParsableException - if the StringBuffer could not be parsedDiscreteGraphicalTrainSM.fromXML(StringBuffer)