|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.models.AbstractModel
de.jstacs.models.discrete.DiscreteGraphicalModel
de.jstacs.models.discrete.homogeneous.HomogeneousModel
de.jstacs.models.discrete.homogeneous.HomogeneousMM
public class HomogeneousMM
This class implements homogeneous Markov models (hMM) of arbitrary order.
HomMMParameterSet
Nested Class Summary |
---|
Nested classes/interfaces inherited from class de.jstacs.models.discrete.homogeneous.HomogeneousModel |
---|
HomogeneousModel.HomCondProb |
Field Summary |
---|
Fields inherited from class de.jstacs.models.discrete.homogeneous.HomogeneousModel |
---|
order, powers |
Fields inherited from class de.jstacs.models.discrete.DiscreteGraphicalModel |
---|
params, trained |
Fields inherited from class de.jstacs.models.AbstractModel |
---|
alphabets, length |
Constructor Summary | |
---|---|
HomogeneousMM(HomMMParameterSet params)
Creates a new homogeneous Markov model from a parameter set. |
|
HomogeneousMM(StringBuffer stringBuff)
The standard constructor for the interface Storable . |
Method Summary | |
---|---|
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 DiscreteGraphicalModel.fromXML(StringBuffer) and DiscreteGraphicalModel.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 double |
probFor(Sequence sequence,
int startpos,
int endpos)
This method computes the probability of the given Sequence in the
given interval. |
protected void |
set(DGMParameterSet 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()
Should give a simple representation (text) of the model as String
. |
void |
train(Sample[] data,
double[][] weights)
Trains the homogeneous model using an array of weighted Sample s. |
void |
train(Sample data,
double[] weights)
Trains the Model object given the data as Sample using
the specified weights. |
Methods inherited from class de.jstacs.models.discrete.homogeneous.HomogeneousModel |
---|
check, chooseFromDistr, cloneHomProb, emitSample, getLogProbFor, getMaximalMarkovOrder, getNumericalCharacteristics, getProbFor, train |
Methods inherited from class de.jstacs.models.discrete.DiscreteGraphicalModel |
---|
fromXML, getCurrentParameterSet, getDescription, getESS, isTrained, toXML |
Methods inherited from class de.jstacs.models.AbstractModel |
---|
getAlphabetContainer, getCharacteristics, getLength, getLogProbFor, getLogProbFor, getLogProbFor, getLogProbFor, getPriorTerm, getProbFor, getProbFor, set, setNewAlphabetContainerInstance, train |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public HomogeneousMM(HomMMParameterSet params) throws CloneNotSupportedException, IllegalArgumentException, NonParsableException
params
- the parameter set
CloneNotSupportedException
- if the parameter set could not be cloned
IllegalArgumentException
- if the parameter set is not instantiated
NonParsableException
- if the parameter set is not parsableHomMMParameterSet
,
HomogeneousModel.HomogeneousModel(de.jstacs.models.discrete.homogeneous.parameters.HomogeneousModelParameterSet)
public HomogeneousMM(StringBuffer stringBuff) throws NonParsableException
Storable
.
Creates a new HomogeneousMM
out of its XML representation.
stringBuff
- the XML representation as StringBuffer
NonParsableException
- if the HomogeneousMM
could not be reconstructed out
of the XML representation (the StringBuffer
could not
be parsed)Storable
Method Detail |
---|
public HomogeneousMM clone() throws CloneNotSupportedException
AbstractModel
Object
's clone()
-method.
clone
in interface Model
clone
in class DiscreteGraphicalModel
AbstractModel
(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
AbstractModel
. 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 o
CloneNotSupportedException
- if something went wrong while cloningprotected Sequence getRandomSequence(Random r, int length) throws WrongAlphabetException, WrongSequenceTypeException
HomogeneousModel
Sequence
from a trained homogeneous
model.
getRandomSequence
in class HomogeneousModel
r
- the random generatorlength
- the length of the Sequence
Sequence
WrongAlphabetException
- if something is wrong with the alphabet
WrongSequenceTypeException
- if the Sequence
type is not suitable (for the
AlphabetContainer
)public String getInstanceName()
Model
public double getLogPriorTerm() throws Exception
Model
Exception
- if something went wrongModel.getPriorTerm()
protected double logProbFor(Sequence sequence, int startpos, int endpos)
HomogeneousModel
Sequence
in the given interval. The method is only used in
Model.getLogProbFor(Sequence, int, int)
after
the method HomogeneousModel.check(Sequence, int, int)
has been
invoked.
logProbFor
in class HomogeneousModel
sequence
- the Sequence
startpos
- the start position within the Sequence
endpos
- the end position within the Sequence
HomogeneousModel.check(Sequence, int, int)
,
Model.getLogProbFor(Sequence, int, int)
protected double probFor(Sequence sequence, int startpos, int endpos)
HomogeneousModel
Sequence
in the
given interval. The method is only used in
Model.getProbFor(Sequence, int, int)
after the
method HomogeneousModel.check(Sequence, int, int)
has been
invoked.
probFor
in class HomogeneousModel
sequence
- the Sequence
startpos
- the start position within the Sequence
endpos
- the end position within the Sequence
HomogeneousModel.check(Sequence, int, int)
,
Model.getProbFor(Sequence, int, int)
public String toString()
Model
String
.
toString
in interface Model
toString
in class DiscreteGraphicalModel
String
public void train(Sample data, double[] weights) throws Exception
Model
Model
object given the data as Sample
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 sample 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 Sample
weights
- the weights of the elements, each weight should be
non-negative
Exception
- if the training did not succeed (e.g. the dimension of
weights
and the number of sequences in the
sample do not match)Sample.getElementAt(int)
,
Sample.ElementEnumerator
public void train(Sample[] data, double[][] weights) throws Exception
HomogeneousModel
Sample
s.
The Sequence
weights in weights[i]
are for the
Sample
in data[i]
.
train
in class HomogeneousModel
data
- the given Sample
sweights
- the weights
Exception
- if something went wrong, furthermore data.length
has to be weights.length
protected StringBuffer getFurtherModelInfos()
DiscreteGraphicalModel
StringBuffer
.
getFurtherModelInfos
in class DiscreteGraphicalModel
DiscreteGraphicalModel.toXML()
protected String getXMLTag()
DiscreteGraphicalModel
DiscreteGraphicalModel.fromXML(StringBuffer)
and DiscreteGraphicalModel.toXML()
.
getXMLTag
in class DiscreteGraphicalModel
DiscreteGraphicalModel.fromXML(StringBuffer)
and
DiscreteGraphicalModel.toXML()
DiscreteGraphicalModel.fromXML(StringBuffer)
,
DiscreteGraphicalModel.toXML()
protected void set(DGMParameterSet params, boolean trained) throws CloneNotSupportedException, NonParsableException
DiscreteGraphicalModel
fromParameterSet
-methods.
set
in class HomogeneousModel
params
- the new ParameterSet
trained
- indicates if the model is trained or not
CloneNotSupportedException
- if the parameter set could not be cloned
NonParsableException
- if the parameters of the model could not be parsedprotected void setFurtherModelInfos(StringBuffer xml) throws NonParsableException
DiscreteGraphicalModel
StringBuffer
.
setFurtherModelInfos
in class DiscreteGraphicalModel
xml
- contains the model information like parameters of the
distribution etc. in XML format
NonParsableException
- if the StringBuffer
could not be parsedDiscreteGraphicalModel.fromXML(StringBuffer)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |