de.jstacs.sequenceScores.statisticalModels.trainable.discrete.inhomogeneous
Class InhomogeneousDGTrainSM

java.lang.Object
  extended by de.jstacs.sequenceScores.statisticalModels.trainable.AbstractTrainableStatisticalModel
      extended by de.jstacs.sequenceScores.statisticalModels.trainable.discrete.DiscreteGraphicalTrainSM
          extended by de.jstacs.sequenceScores.statisticalModels.trainable.discrete.inhomogeneous.InhomogeneousDGTrainSM
All Implemented Interfaces:
InstantiableFromParameterSet, SequenceScore, StatisticalModel, TrainableStatisticalModel, Storable, Cloneable
Direct Known Subclasses:
DAGTrainSM, MEManager

public abstract class InhomogeneousDGTrainSM
extends DiscreteGraphicalTrainSM

This class is the main class for all inhomogeneous discrete graphical models (InhomogeneousDGTrainSM).

Author:
Jens Keilwagen
See Also:
IDGTrainSMParameterSet

Field Summary
protected static OutputStream DEFAULT_STREAM
          The default OutputStream.
protected  SafeOutputStream sostream
          This stream is used for comments, computation steps/results or any other kind of output during the training, ...
 
Fields inherited from class de.jstacs.sequenceScores.statisticalModels.trainable.discrete.DiscreteGraphicalTrainSM
params, trained
 
Fields inherited from class de.jstacs.sequenceScores.statisticalModels.trainable.AbstractTrainableStatisticalModel
alphabets, length
 
Constructor Summary
InhomogeneousDGTrainSM(IDGTrainSMParameterSet params)
          Creates a new InhomogeneousDGTrainSM from a given IDGTrainSMParameterSet.
InhomogeneousDGTrainSM(StringBuffer representation)
          The standard constructor for the interface Storable.
 
Method Summary
protected  void check(Sequence sequence, int startpos, int endpos)
          Checks some conditions on a Sequence.
 InhomogeneousDGTrainSM clone()
          Follows the conventions of Object's clone()-method.
abstract  String getStructure()
          Returns a String representation of the underlying graph.
protected  void set(DGTrainSMParameterSet parameter, boolean trained)
          Sets the parameters as internal parameters and does some essential computations.
 void setOutputStream(OutputStream stream)
          Sets the OutputStream for the model.
 
Methods inherited from class de.jstacs.sequenceScores.statisticalModels.trainable.discrete.DiscreteGraphicalTrainSM
fromXML, getCurrentParameterSet, getDescription, getESS, getFurtherModelInfos, getXMLTag, isInitialized, setFurtherModelInfos, toString, toXML
 
Methods inherited from class de.jstacs.sequenceScores.statisticalModels.trainable.AbstractTrainableStatisticalModel
emitDataSet, getAlphabetContainer, getCharacteristics, getLength, getLogProbFor, getLogProbFor, getLogScoreFor, getLogScoreFor, getLogScoreFor, getLogScoreFor, getLogScoreFor, getMaximalMarkovOrder, toString, train
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.jstacs.sequenceScores.statisticalModels.trainable.TrainableStatisticalModel
train
 
Methods inherited from interface de.jstacs.sequenceScores.statisticalModels.StatisticalModel
getLogPriorTerm, getLogProbFor
 
Methods inherited from interface de.jstacs.sequenceScores.SequenceScore
getInstanceName, getNumericalCharacteristics
 

Field Detail

sostream

protected SafeOutputStream sostream
This stream is used for comments, computation steps/results or any other kind of output during the training, ... etc.


DEFAULT_STREAM

protected static final OutputStream DEFAULT_STREAM
The default OutputStream.

Constructor Detail

InhomogeneousDGTrainSM

public InhomogeneousDGTrainSM(IDGTrainSMParameterSet params)
                       throws CloneNotSupportedException,
                              IllegalArgumentException,
                              NonParsableException
Creates a new InhomogeneousDGTrainSM from a given IDGTrainSMParameterSet.

Parameters:
params - the given parameter set
Throws:
CloneNotSupportedException - if the parameter set could not be cloned
IllegalArgumentException - if the parameter set is not instantiated
NonParsableException - if the parameter set is not parsable
See Also:
DiscreteGraphicalTrainSM.DiscreteGraphicalTrainSM(DGTrainSMParameterSet)

InhomogeneousDGTrainSM

public InhomogeneousDGTrainSM(StringBuffer representation)
                       throws NonParsableException
The standard constructor for the interface Storable. Creates a new InhomogeneousDGTrainSM out of its XML representation.

Parameters:
representation - the XML representation as StringBuffer
Throws:
NonParsableException - if the InhomogeneousDGTrainSM could not be reconstructed out of the XML representation (the StringBuffer could not be parsed)
See Also:
Storable, DiscreteGraphicalTrainSM.DiscreteGraphicalTrainSM(StringBuffer)
Method Detail

clone

public InhomogeneousDGTrainSM clone()
                             throws CloneNotSupportedException
Description copied from class: AbstractTrainableStatisticalModel
Follows the conventions of Object's clone()-method.

Specified by:
clone in interface SequenceScore
Specified by:
clone in interface TrainableStatisticalModel
Overrides:
clone in class DiscreteGraphicalTrainSM
Returns:
an object, that is a copy of the current AbstractTrainableStatisticalModel (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:
1. Object o = (X)super.clone();
2. all additional member variables of o defined by X that are not of simple data-types like int, double, ... have to be deeply copied
3. return o
Throws:
CloneNotSupportedException - if something went wrong while cloning

getStructure

public abstract String getStructure()
                             throws NotTrainedException
Returns a String representation of the underlying graph.

Returns:
a String representation of the underlying graph
Throws:
NotTrainedException - if the structure is not set, this can only be the case if the model is not trained

setOutputStream

public void setOutputStream(OutputStream stream)
Sets the OutputStream for the model. This stream will sometimes be used to write some information about the training/progress/computation... etc. to the screen, a file ... etc.

Parameters:
stream - the OutputStream
See Also:
SafeOutputStream

check

protected void check(Sequence sequence,
                     int startpos,
                     int endpos)
              throws NotTrainedException,
                     IllegalArgumentException
Description copied from class: DiscreteGraphicalTrainSM
Checks some conditions on a Sequence. These are in general conditions on the AlphabetContainer of a (sub) Sequence between startpos und endpos.

Overrides:
check in class DiscreteGraphicalTrainSM
Parameters:
sequence - the Sequence
startpos - the startposition
endpos - the endposition
Throws:
NotTrainedException - if the model is not trained
IllegalArgumentException - if some constraints are not fulfilled

set

protected void set(DGTrainSMParameterSet parameter,
                   boolean trained)
            throws CloneNotSupportedException,
                   NonParsableException
Description copied from class: DiscreteGraphicalTrainSM
Sets the parameters as internal parameters and does some essential computations. Used in fromParameterSet-methods.

Overrides:
set in class DiscreteGraphicalTrainSM
Parameters:
parameter - the new ParameterSet
trained - indicates if the model is trained or not
Throws:
CloneNotSupportedException - if the parameter set could not be cloned
NonParsableException - if the parameters of the model could not be parsed