|
||||||||||
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.inhomogeneous.InhomogeneousDGM
de.jstacs.models.discrete.inhomogeneous.DAGModel
de.jstacs.models.discrete.inhomogeneous.BayesianNetworkModel
public class BayesianNetworkModel
The class implements a Bayesian network (
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
Field Summary |
---|
Fields inherited from class de.jstacs.models.discrete.inhomogeneous.DAGModel |
---|
constraints |
Fields inherited from class de.jstacs.models.discrete.inhomogeneous.InhomogeneousDGM |
---|
DEFAULT_STREAM, sostream |
Fields inherited from class de.jstacs.models.discrete.DiscreteGraphicalModel |
---|
params, trained |
Fields inherited from class de.jstacs.models.AbstractModel |
---|
alphabets, length |
Constructor Summary | |
---|---|
BayesianNetworkModel(BayesianNetworkModelParameterSet params)
Creates a new BayesianNetworkModel from a given
BayesianNetworkModelParameterSet . |
|
BayesianNetworkModel(StringBuffer representation)
The standard constructor for the interface Storable . |
Method Summary | |
---|---|
BayesianNetworkModel |
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 DiscreteGraphicalModel.fromXML(StringBuffer) and DiscreteGraphicalModel.toXML() . |
protected void |
set(DGMParameterSet parameter,
boolean trained)
Sets the parameters as internal parameters and does some essential computations. |
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.inhomogeneous.DAGModel |
---|
checkAcyclic, createConstraints, drawParameters, emitSample, estimateParameters, getFurtherModelInfos, getLogProbFor, getNumericalCharacteristics, getProbFor, getStructure, setFurtherModelInfos, toString |
Methods inherited from class de.jstacs.models.discrete.inhomogeneous.InhomogeneousDGM |
---|
check, setOutputStream |
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 BayesianNetworkModel(BayesianNetworkModelParameterSet params) throws CloneNotSupportedException, IllegalArgumentException, NonParsableException
BayesianNetworkModel
from a given
BayesianNetworkModelParameterSet
.
params
- the given 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 parsableDAGModel.DAGModel(de.jstacs.models.discrete.inhomogeneous.parameters.IDGMParameterSet)
public BayesianNetworkModel(StringBuffer representation) throws NonParsableException
Storable
.
Creates a new BayesianNetworkModel
out of its XML representation.
representation
- the XML representation as StringBuffer
NonParsableException
- if the BayesianNetworkModel
could not be
reconstructed out of the XML representation (the
StringBuffer
could not be parsed)Storable
,
DAGModel.DAGModel(StringBuffer)
Method Detail |
---|
public BayesianNetworkModel clone() throws CloneNotSupportedException
AbstractModel
Object
's clone()
-method.
clone
in interface Model
clone
in class DAGModel
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 cloningpublic String getInstanceName()
Model
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()
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 double getLogPriorTerm() throws Exception
Model
getLogPriorTerm
in interface Model
getLogPriorTerm
in class DAGModel
Exception
- if something went wrongModel.getPriorTerm()
public byte getMaximalMarkovOrder()
Model
getMaximalMarkovOrder
in interface Model
getMaximalMarkovOrder
in class AbstractModel
protected int[] count(int[][] structure, byte maxOrder)
structure
- the structuremaxOrder
- the maximal order
int
-array containing the occurrence of indegreesprotected void set(DGMParameterSet parameter, boolean trained) throws CloneNotSupportedException, NonParsableException
DiscreteGraphicalModel
fromParameterSet
-methods.
set
in class InhomogeneousDGM
parameter
- 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 parsed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |