public class BayesianNetworkTrainSM extends DAGTrainSM
StructureLearner.ModelType.BN
) of fixed order. It allows the user to
specify some kinds of specializations of BNs including inhomogeneous Markov
models ( StructureLearner.ModelType.IMM
) and permuted Markov models
( StructureLearner.ModelType.PMM
).StructureLearner.ModelType
constraints
DEFAULT_STREAM, sostream
params, trained
alphabets, length
Constructor and Description |
---|
BayesianNetworkTrainSM(BayesianNetworkTrainSMParameterSet params)
Creates a new
BayesianNetworkTrainSM from a given
BayesianNetworkTrainSMParameterSet . |
BayesianNetworkTrainSM(StringBuffer representation)
The standard constructor for the interface
Storable . |
Modifier and Type | Method and Description |
---|---|
BayesianNetworkTrainSM |
clone()
Follows the conventions of
Object 's clone() -method. |
protected int[] |
count(int[][] structure,
byte maxOrder)
Counts the occurrence of the different indegrees and checks if the
conventions are met.
|
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.
|
byte |
getMaximalMarkovOrder()
This method returns the maximal used Markov order, if possible.
|
protected String |
getXMLTag()
Returns the XML tag that is used for this model in
DiscreteGraphicalTrainSM.fromXML(StringBuffer) and DiscreteGraphicalTrainSM.toXML() . |
protected void |
set(DGTrainSMParameterSet parameter,
boolean trained)
Sets the parameters as internal parameters and does some essential
computations.
|
void |
train(DataSet data,
double[] weights)
Trains the
TrainableStatisticalModel object given the data as DataSet using
the specified weights. |
checkAcyclic, createConstraints, drawParameters, emitDataSet, estimateParameters, getFurtherModelInfos, getLogProbFor, getNumericalCharacteristics, getStructure, setFurtherModelInfos, toString
check, setOutputStream
fromXML, getCurrentParameterSet, getDescription, getESS, isInitialized, toXML
getAlphabetContainer, getCharacteristics, getLength, getLogProbFor, getLogProbFor, getLogScoreFor, getLogScoreFor, getLogScoreFor, getLogScoreFor, getLogScoreFor, toString, train
public BayesianNetworkTrainSM(BayesianNetworkTrainSMParameterSet params) throws CloneNotSupportedException, IllegalArgumentException, NonParsableException
BayesianNetworkTrainSM
from a given
BayesianNetworkTrainSMParameterSet
.params
- the given parameter setCloneNotSupportedException
- if the parameter set could not be clonedIllegalArgumentException
- if the parameter set is not instantiatedNonParsableException
- if the parameter set is not parsableDAGTrainSM.DAGTrainSM(de.jstacs.sequenceScores.statisticalModels.trainable.discrete.inhomogeneous.parameters.IDGTrainSMParameterSet)
public BayesianNetworkTrainSM(StringBuffer representation) throws NonParsableException
Storable
.
Creates a new BayesianNetworkTrainSM
out of its XML representation.representation
- the XML representation as StringBuffer
NonParsableException
- if the BayesianNetworkTrainSM
could not be
reconstructed out of the XML representation (the
StringBuffer
could not be parsed)Storable
,
DAGTrainSM.DAGTrainSM(StringBuffer)
public BayesianNetworkTrainSM clone() throws CloneNotSupportedException
AbstractTrainableStatisticalModel
Object
's clone()
-method.clone
in interface SequenceScore
clone
in interface TrainableStatisticalModel
clone
in class DAGTrainSM
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: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 cloningpublic String getInstanceName()
SequenceScore
protected String getXMLTag()
DiscreteGraphicalTrainSM
DiscreteGraphicalTrainSM.fromXML(StringBuffer)
and DiscreteGraphicalTrainSM.toXML()
.getXMLTag
in class DiscreteGraphicalTrainSM
DiscreteGraphicalTrainSM.fromXML(StringBuffer)
and
DiscreteGraphicalTrainSM.toXML()
DiscreteGraphicalTrainSM.fromXML(StringBuffer)
,
DiscreteGraphicalTrainSM.toXML()
public void train(DataSet data, double[] weights) throws Exception
TrainableStatisticalModel
TrainableStatisticalModel
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 DataSet
weights
- 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.ElementEnumerator
public double getLogPriorTerm() throws Exception
StatisticalModel
getLogPriorTerm
in interface StatisticalModel
getLogPriorTerm
in class DAGTrainSM
Exception
- if something went wrongpublic byte getMaximalMarkovOrder()
StatisticalModel
getMaximalMarkovOrder
in interface StatisticalModel
getMaximalMarkovOrder
in class AbstractTrainableStatisticalModel
protected int[] count(int[][] structure, byte maxOrder)
structure
- the structuremaxOrder
- the maximal orderint
-array containing the occurrence of indegreesprotected void set(DGTrainSMParameterSet parameter, boolean trained) throws CloneNotSupportedException, NonParsableException
DiscreteGraphicalTrainSM
fromParameterSet
-methods.set
in class InhomogeneousDGTrainSM
parameter
- the new ParameterSet
trained
- 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 parsed