Domain
public class Domain : Network
Instances of the Domain class represent Bayesian networks and
LIMIDs in which you can propagate evidence and calculate updated
beliefs and expected utilities.
Domain objects are automatically deallocated when the last
reference to the object disappears. When this happens, all objects
“owned” by the Domain object (such as Node objects) are
deleted, so make sure to hold on to the Domain object until it is
no longer needed.
-
Constructs a new empty
Domain.Declaration
Swift
public init(license: License? = nil) throwsParameters
licenselicense data to be used instead of a license file.
-
Constructs a
Domainby loading the corresponding Hugin Knowledge Base (HKB) file. The HKB file must contain a domain.Declaration
Swift
public init(hkbName: String, password: String? = nil, license: License? = nil) throwsParameters
hkbNamethe name of the HKB file
passworda password needed to load the file
licenselicense data to be used instead of a license file.
-
Saves this
Domainas a Hugin Knowledge Base (HKB) file. Ifpasswordis non-nil, the file will be password protected. This password must be used in order to load the file.See also
Declaration
Swift
public func save(hkbName: String, password: String? = nil) throwsParameters
hkbNamethe name of the HKB file to create
passwordif non-
nil, this must be used in order to load the HKB file. -
Constructs a
Domainfrom a NET file.Declaration
Swift
public init(netName: String, license: License? = nil) throwsParameters
netNamethe name of the NET file
licenselicense data to be used instead of a license file.
-
Constructs a
Domainfrom a NET description provided as a string.See also
Declaration
Swift
public init(netString: String, license: License? = nil) throwsParameters
netStringthe NET description
licenselicense data to be used instead of a license file.
-
Constructs a DBN runtime domain from a
Classobject. The domain is formed by linking (through temporal clones) the specified number of instances (called time slices) of the class.Declaration
Swift
public init(_ cls: Class, _ numberOfSlices: Int) throwsParameters
clsthe
Classobject describing a single time slicenumberOfSlicesthe number of time slices
-
Constructs a domain by cloning the given
Domainobject.Declaration
Swift
public init(_ domain: Domain) throwsParameters
domainthe
Domainobject to clone. -
The TriangulationMethod type represents the triangulation method used for this
See moreDomain. Triangulation is the process of transforming the graph of aDomainto a triangulated graph, which forms the basis for constructing the JunctionTree of theDomain.Declaration
Swift
public enum TriangulationMethod -
Triangulates the graph of this
Domainusing the specified triangulation method.Declaration
Swift
public func triangulate(_ tm: TriangulationMethod) throwsParameters
tmthe TriangulationMethod to use.
-
Triangulates the graph of this
Domainusing the specified elimination order. The elimination order must contain each chance and decision node of thisDomainexactly once, and continuous nodes must appear before discrete nodes.Declaration
Swift
public func triangulate(_ order: [Node]) throwsParameters
ordera NodeList containing the Nodes of the network in the order of elimination
-
Returns the triangulation order. A NodeList containing the nodes in the order used to triangulate the network of this
Domainis returned.Declaration
Swift
public func getEliminationOrder() throws -> [Node]Return Value
NodeList containing Nodes representing the elimination order used.
-
Tests whether this
Domainis triangulated. Being “triangulated” means that the junction forest has been created, but not the associated tables.Declaration
Swift
public func isTriangulated() throws -> Bool -
Compiles this
Domain. The domain must not be compiled. The default triangulation method is used (unless the domain is already triangulated, in which case the existing triangulation is used).Declaration
Swift
public func compile() throws -
Tests whether this
Domainis compiled. A domain is “compiled” if it is triangulated and junction tree tables are created.Declaration
Swift
public func isCompiled() throws -> Bool -
Uncompiles this
Domain. Removes the data structures of theDomainproduced by a triangulation or a compilation. Note that any references to objects within the compiled structure (e.g., Cliques and JunctionTrees) are invalidated (that is, any attempt to access the objects will throw an object-not-alive exception). Also note that many of the editing functions automatically performs an uncompile() operation. When this happens, the domain must be compiled again before it can be used for inference.Declaration
Swift
public func uncompile() throws -
Sets an initial triangulation for this
Domainfor use by thetotalWeighttriangulation method. The purpose is to (1) improve the generated triangulation, and (2) to reduce the run-time of the algorithm. The triangulation must be specified in the form of an elimination sequence.Declaration
Swift
public func setInitialTriangulation(_ order: [Node]) throwsParameters
ordera list of
Nodes of the network in the order of elimination. -
Sets the maximum number of separators allowed when using the
totalWeighttriangulation method. No value (nil) specifies an unbounded number of separators.Declaration
Swift
public func setMaxNumberOfSeparators(_ m: Int?) throws -
Sets the maximum separator size for the
totalWeighttriangulation method. If a maximum separator size is specified, then separators larger than the specified size will be discarded by the separator generation algorithm. However, separators implied by the initial triangulation will be retained (regardless of size). This feature can be used to triangulate much larger graphs (without splitting them into smaller subgraphs). But notice that not all separators up to the specified limit are necessarily generated.An initial triangulation is required in order to use this feature.
If no maximum size (
nil) is specified, then no separators will be discarded.See also
Domain.setInitialTriangulation([Node])Declaration
Swift
public func setMaxSeparatorSize(_ size: Int?) throws -
Returns the maximum number of separators allowed when using the
totalWeighttriangulation method.See also
Domain.setMaxNumberOfSeparators(Int?)Declaration
Swift
public func getMaxNumberOfSeparators() throws -> Int? -
Returns the maximum separator size allowed when using the
totalWeighttriangulation method.See also
Domain.setMaxSeparatorSize(Int?)Declaration
Swift
public func getMaxSeparatorSize() throws -> Int? -
Removes “near-zero” probabilities from the clique probability tables. For each Clique in this domain, a value delta is computed such that the sum of all elements less than delta in the (discrete part) of the clique table is less than epsilon. These elements (less than delta) are then set to 0.
Declaration
Swift
public func approximate(_ epsilon: Double) throws -> DoubleParameters
epsilonthe threshold value. Maximal probability mass to eradicate from each clique.
Return Value
The probability mass remaining in the entire
Domain, letting you know how much precision you have “lost”. Note that this is not the same as 1 - e, as the e value is relative to each clique. Typically, the amount of probability mass removed will be somewhat larger than e. -
Returns the approximation constant. The number returned is based on the most recent (explicit or implicit) approximation operation. An implicit approximation takes place when you change some conditional probability tables of a compressed domain, and then perform a propagation operation. Since some (discrete) state configurations have been removed from a compressed domain, the probability mass of the remaining configurations will typically be less than 1. This probability mass is returned by getApproximationConstant().
Declaration
Swift
public func getApproximationConstant() throws -> DoubleReturn Value
A real number expressing the probability mass remaining in the approximated domain.
-
Removes the zero entries from the clique and separator tables of the JunctionTrees in this
Domain. Compression can only be applied to (compiled) ordinary Bayesian networks. Continuous nodes are allowed, but compression only applies to configurations of states of the discrete nodes.Declaration
Swift
public func compress() throws -> DoubleReturn Value
A double value which indicates a measure of compression achieved. The measure should be less than 1, indicating that the compressed
Domainrequires less space than the uncompressedDomain. An output greater than 1 means that the “compressed”Domainrequires more space than the uncompressedDomain. -
Tests whether this
Domainis compressed.Declaration
Swift
public func isCompressed() throws -> Bool -
Returns the JunctionTrees of this
Domain.Declaration
Swift
public func getJunctionTrees() throws -> [JunctionTree] -
Retracts (all) evidence for all nodes in this
Domain.Declaration
Swift
public func retractFindings() throws -
Performs a d-separation test and returns a list of d-connected nodes. Assuming evidence on the specified evidence nodes, this method returns the list of nodes that are d-connected to the specified list of source nodes.
Declaration
Parameters
sourcelist of source nodes
hardlist of nodes assumed to be instantiated
softlist of nodes assumed to have multi-state or likelihood evidence.
Return Value
the list of d-connected nodes
-
Performs a d-separation test and returns a list of d-separated nodes. Assuming evidence on the specified evidence nodes, this method returns the list of nodes that are d-separated to the specified list of source nodes.
Declaration
Parameters
sourcelist of source nodes
hardlist of nodes assumed to be instantiated
softlist of nodes assumed to have multi-state or likelihood evidence.
Return Value
the list of d-separated nodes
-
Computes the marginal distribution for the Nodes provided as argument with respect to the (imaginary) joint potential, determined by the current potentials on the JunctionTree(s) of this
Domain. Ifnodescontains continuous nodes, they must be last in the list. This operation is not allowed on compressedDomains.Parameters
nodesa NodeList containing the Nodes over which to compute the marginal.
Return Value
A Table containing the marginal distribution over the Nodes in
nodes. -
Returns the total expected utility associated with this
Domain.Declaration
Swift
public func getExpectedUtility() throws -> Double -
Parses the case stored in file
fileNameand enters the associated findings into thisDomain. All existing evidence in theDomainis retracted before entering the case findings.Declaration
Swift
public func parseCase (_ fileName: String) throwsParameters
fileNamethe name of the file containing the case.
-
Saves all evidence entered in this
Domainin filefileName(if the file exists, it is overwritten).Declaration
Swift
public func saveCase(_ fileName: String) throwsParameters
fileNamethe name of the file in which the case is going to be saved.
-
The
Equilibriumtype represents the equilibrium state of thisDomain.See moreSee also
Domain.propagate(equilibrium:mode:)Declaration
Swift
public enum Equilibrium -
The EvidenceMode type represents the mode used for propagating evidence in this
Domain.See moreSee also
Domain.propagate(equilibrium:mode:)Declaration
Swift
public enum EvidenceMode -
Establishes the specified equilibrium using the evidence mode indicated for incorporation of evidence on all
JunctionTrees of thisDomain. Also, revised beliefs will be computed for all nodes.Declaration
Swift
public func propagate (equilibrium: Equilibrium = .sum, mode: EvidenceMode = .normal) throwsParameters
equilibriumThe type of equilibrium to establish. The default type is
Domain.Equilibrium.sum.modeThe evidence mode to use. The default mode is
Domain.EvidenceMode.normal. -
Tests for Equilibrium type. Returns
trueif the equilibrium states of all JunctionTrees of thisDomainare identical toequilibrium.Declaration
Swift
public func equilibriumIs(_ equilibrium: Equilibrium) throws -> BoolParameters
equilibriumthe type of equilibrium to test for.
-
Tests for evidence mode. Returns
trueif the equilibrium states of all JunctionTrees of thisDomaincould have been obtained through a propagation usingevidenceModeas the evidence incorporation mode. Otherwise, returnsfalse.Declaration
Swift
public func evidenceModeIs(_ evidenceMode: EvidenceMode) throws -> BoolParameters
evidenceModethe type of EvidenceMode to test for.
-
Updates the policy tables of the domain. The policies of all unmade decisions are updated. The new policies maximize the overall expected utility.
Declaration
Swift
public func updatePolicies() throws -
Retrieves the normalization constant for the most recent propagation. For sum-propagation, the normalization constant is equal to the probability of the evidence propagated. For max-propagation, the normalization constant is the probability of the most probable configuration with the evidence incorporated.
Declaration
Swift
public func getNormalizationConstant() throws -> Double -
Returns the logarithm of the normalization constant.
Declaration
Swift
public func getLogNormalizationConstant() throws -> Double -
Returns the conflict value. The conflict value is valid for this
Domaincomputed during the most recent propagation. If no propagation has been performed, 1 is returned.Declaration
Swift
public func getConflict() throws -> DoubleReturn Value
A double-precision real value expressing the conflict measure in the domain.
-
Creates a copy in memory of the belief and JunctionTree tables of this
Domain. This operation can only be performed if the domain is compiled, the current equilibrium equalsDomain.Equilibrium.sum, and no evidence has been incorporated.Declaration
Swift
public func saveToMemory() throws -
Establishes the initial state of the inference engine, which is sum-equilibrium with no evidence incorporated. Any propagated evidence will thus be removed from the JunctionTree potentials, but entered evidence will still be “registered” (i.e., they will be incorporated in the next propagation).
Declaration
Swift
public func resetInferenceEngine() throws -
Establishes the initial values for all tables of this
Domain(which must be compiled). This method erases all evidence previously entered.Declaration
Swift
public func initialize() throws -
Tests if evidence has been propagated for this
Domain. Returnstrueif it has; otherwise, returnsfalse.Declaration
Swift
public func evidenceIsPropagated() throws -> Bool -
Tests if evidence has been entered since the last propagation. Returns
trueif it has; otherwise, returnsfalse.Declaration
Swift
public func evidenceToPropagate() throws -> Bool -
Tests if likelihood evidence has been propagated for this
Domain. Returnstrueif it has; otherwise, returnsfalse.Declaration
Swift
public func likelihoodIsPropagated() throws -> Bool -
Returns
trueif evidence on CG nodes has been propagated; otherwise, returnsfalse.Declaration
Swift
public func cgEvidenceIsPropagated() throws -> Bool -
Tests for new node tables. Returns
trueif there is a node in thisDomainhaving a (conditional probability, policy, or utility) table that has changed since the most recent compilation or propagation; otherwise, returnsfalse.Declaration
Swift
public func tablesToPropagate() throws -> Bool -
Generates a sample configuration from the joint distribution represented by this
Domain. Given evidence, we may be interested in generating (sampling) configurations (i.e., vectors of values over the set of variables in the network) with respect to the conditional distribution for the evidence. If theDomainis compiled, a configuration is sampled with respect to the current distribution represented by the JunctionTree(s). This distribution must be in sum-equilibrium with evidence incorporated in normal mode.Declaration
Swift
public func simulate() throws -
Seeds the pseudo-random number generator for this
Domain. The configurations generated by simulate are not really random. They are generated using a pseudo-random number generator producing a sequence of numbers that although it appears random is actually completely deterministic. To change the starting point for the generator, use this method.Declaration
Swift
public func seedRandom(_ seed: UInt32) throwsParameters
seedthe seed number.
-
Use the pseudo-random number generator for this
Domainto sample a real number from the uniform distribution over the interval [0,1).Declaration
Swift
public func getUniformDeviate() throws -> Double -
Use the pseudo-random number generator for this
Domainto sample a real number from a normal (aka Gaussian) distribution.Declaration
Swift
public func getNormalDeviate (_ mean: Double, _ variance: Double) throws -> DoubleParameters
meanthe mean of the distribution
variancethe variance of the distribution
-
Computes the constants of the sensitivity functions for the specified output probabilities and all CPT parameters in the network. The output probabilities are specified using a list of (discrete chance) nodes and a list of corresponding states.
Declaration
Swift
public func computeSensitivityData (_ nodes: [Node], _ states: [Int]) throwsParameters
nodesthe list of (output) nodes
statesa list of states of the nodes in the
nodeslist -
Returns the sensitivity set computed by the most recent call to
Node.computeSensitivityData(Int). If the results produced by that call have been invalidated, a usage error is thrown.Declaration
Swift
public func getSensitivitySet() throws -> [Node] -
Returns the sensitivity set computed by the most recent call to
Domain.computeSensitivityData([Node],[Int]). If the results produced by that call have been invalidated, a usage error is thrown.Declaration
Swift
public func getSensitivitySet(_ output: Int) throws -> [Node]Parameters
outputidentifies one of the output probabilities specified in the call to
Domain.computeSensitivityData([Node],[Int]). -
Finds all configurations of
nodeswith probability at leastminProbability. This method uses a Monte Carlo algorithm to solve a generalized form of the maximum a posteriori (MAP) configuration problem: The MAP configuration problem is the problem of finding the most probable configuration of a set of nodes given evidence on some of the remaining nodes.The results of this method are provided by
Domain.getNumberOfMAPConfigurations(),Domain.getMAPConfiguration(Int), andDomain.getProbabilityOfMAPConfiguration(Int).Declaration
Swift
public func findMAPConfigurations (_ nodes: [Node], _ minProbability: Double) throwsParameters
nodesa list of discrete nodes for which to find configurations.
minProbabilityconfigurations with a lower probability than
minProbabilityare ignored. -
Returns the number of MAP configurations. This method returns the number of configurations found by the most recent successful call to
Domain.findMAPConfigurations([Node],Double).Declaration
Swift
public func getNumberOfMAPConfigurations() throws -> Int -
This method returns the MAP configuration identified by
indexamong the configurations with probability at leastminProbability— as specified in the most recent successful call toDomain.findMAPConfigurations([Node],Double).The
indexargument must be a nonnegative integer less than the number of MAP configurations found: 0 requests the most probable configuration, 1 the second-most probable configuration, etc.Declaration
Swift
public func getMAPConfiguration(_ index: Int) throws -> [Int]Parameters
indexidentifies the configuration.
Return Value
an array of state indexes forming the configuration.
-
This method returns the probability of the MAP configuration returned by
Domain.getMAPConfiguration(index).Declaration
Swift
public func getProbabilityOfMAPConfiguration (_ index: Int) throws -> DoubleParameters
indexidentifies the configuration.
Return Value
the probability of the specified configuration.
-
Returns the number of explanations. This method returns the number of subsets found by the most recent successful call to
Node.computeExplanationData(Int,Node,Int,Int).Declaration
Swift
public func getNumberOfExplanations() throws -> Int -
Returns the evidence subset associated with the explanation of rank
indexcomputed by the most recent call toNode.computeExplanationData(Int,Node,Int,Int).Declaration
Swift
public func getExplanation(_ index: Int) throws -> [Node]Parameters
indexspecifies that the
indexth best explanation should be retrieved (the best explanation has index 0, the second best has index 1, etc.) -
Returns the score of the specified explanation. This method returns the score associated with the explanation subset returned by
Domain.getExplanation(index).Declaration
Swift
public func getExplanationScore(_ index: Int) throws -> DoubleParameters
indexidentifies the explanation.
-
Adapts this
Domainaccording to the evidence propagated.Declaration
Swift
public func adapt() throws -
Adapts (using the Fractional Update algorithm) the tables of the nodes in the class with the evidence propagated in this runtime
Domain. This method must be called on a runtime domain. The evidence propagated in this domain is used to adapt the tables of the class from which this domain was created. The updated tables are copied back to the nodes of the runtime domain.Declaration
Swift
public func adaptClassTablesUsingFractionalUpdate() throws -
Adapts (using the Online EM algorithm) the tables of the nodes in the class with the evidence propagated in this runtime
Domain. This method must be called on a runtime domain. The evidence propagated in this domain is used to adapt the tables of the class from which this domain was created. The updated tables are copied back to the nodes of the runtime domain.Declaration
Swift
public func adaptClassTablesUsingOnlineEM(_ rho: Double) throwsParameters
rhothe parameter used to determine the “learning rate” of the Online EM algorithm.
-
Sets the number of cases.
Declaration
Swift
public func setNumberOfCases(_ size: Int) throws -
Creates a new case.
Declaration
Swift
public func newCase() throws -> IntReturn Value
the index of the new case
-
Returns the number of data cases.
Declaration
Swift
public func getNumberOfCases() throws -> Int -
Sets case count for a case.
Declaration
Swift
public func setCaseCount(_ index: Int, _ count: Double) throwsParameters
indexthe index of the case for which to set the count.
countthe multiplicity of case
index. -
Returns case count for a case.
Declaration
Swift
public func getCaseCount(_ index: Int) throws -> DoubleParameters
indexthe index of the case for which to get the count.
Return Value
The multiplicity of case
index. -
Enters a case as evidence.
Declaration
Swift
public func enterCase(_ index: Int) throwsParameters
indexthe index of the case to enter.
-
Parses the cases stored in file
fileNameand enters the cases into thisDomain.Declaration
Swift
public func parseCases (_ fileName: String) throwsParameters
fileNamethe name of the file containing the cases.
-
Saves all cases entered in this
Domainin a file with the givenfileName(if the file exists, it is overwritten).Declaration
Swift
public func saveCases (_ fileName: String, _ nodes: [Node], _ cases: [Int]? = nil, includeCaseCounts: Bool = false, separator: String = ",", missingData: String = "*") throwsParameters
fileNamethe name of the file in which the cases will be saved.
nodesA list of all nodes which are to be included in the file
casesAn array of case indexes specifying the cases to be included in the file. Passing
nilfor this argument will include all cases.includeCaseCountsIf true, include case counts in the data file. If false, only include case counts if they are present in the domain.
separatorThe string used to seperate the items in the file
missingDataThe string used to represent missing data
-
Computes the log-likelihood of the case data.
Declaration
Swift
public func getLogLikelihood() throws -> Double -
Computes the AIC score (Akaike’s Information Criterion) of the case data.
Declaration
Swift
public func getAIC() throws -> Double -
Computes the BIC score (Bayesian Information Criterion) of the case data.
Declaration
Swift
public func getBIC() throws -> Double -
Learn the structure (graph) of the Bayesian network from data using the PC-algorithm.
The domain must contain only chance nodes and no edges. Case data must be specified in advance.
Declaration
Swift
public func learnStructure() throws -
Learns a tree-structured network model from data. If
rootis non-nil, then a Chow-Liu tree model withrootas root is learned. Then, iftargetis also non-nil, this tree is turned into a TAN model by addingtargetas parent of all other nodes of thisDomain. Ifrootandtargetare bothnil, then a Rebane-Pearl polytree model is learned.The domain must contain only chance nodes and no edges. Case data must be specified in advance.
Parameters
rootall edges of the Chow-Liu tree will be directed away from
roottargetthe class variable of the TAN model.
-
Learns a Hierarchical Naive Bayes (HNB) model from data.
The domain must contain only chance nodes (but continuous nodes are ignored by the HNB algorithm) and no edges. The
targetvariable must be a discrete node. Case data must be specified in advance.Declaration
Swift
public func learnHNBStructure (target: Node) throwsParameters
targetthe class variable of the HNB model.
-
Fine-tunes a Naive Bayes (NB) model using training data.
The method makes small adjustments to the conditional probabilities of the attribute nodes in order to obtain more correct classifications. If these adjustments do not result in a better model, the original model is preserved.
The domain must represent a Naive Bayes model with initial conditional probability tables (for example, estimated using the EM algorithm). The network must contain only discrete chance nodes. Case data must be specified in advance.
Declaration
Swift
public func fineTuneNBTables (target: Node) throwsParameters
targetthe class variable of the Naive Bayes model.
-
Sets the learning rate of the Naive Bayes (NB) fine-tuning algorithm. The default value is 0.01.
Declaration
Swift
public func setNBFineTuneLearningRate(_ learningRate: Double) throwsParameters
learningRatea number between 0 and 1.
-
Returns the learning rate of the Naive Bayes (NB) fine-tuning algorithm. The default value is 0.01.
Declaration
Swift
public func getNBFineTuneLearningRate() throws -> DoubleReturn Value
A number between 0 and 1.
-
Sets the limit for the number of consecutive failed iterations of the Naive Bayes (NB) fine-tuning algorithm. When
limititerations over the training data, showing no improvements of the classification accuracy, have been performed, the algorithm terminates.The default value is 1.
Declaration
Swift
public func setNBFineTuneIterationsLimit(_ limit: Int) throwsParameters
limita positive integer.
-
Returns the limit for the number of consecutive failed iterations of the Naive Bayes (NB) fine-tuning algorithm.
Declaration
Swift
public func getNBFineTuneIterationsLimit() throws -> Int -
Sets the significance level of the dependency tests performed during structure learning using the PC-algorithm. The default value is 0.05.
Declaration
Swift
public func setSignificanceLevel(_ alpha: Double) throwsParameters
alphathe significance level.
-
Returns the significance level of the dependency tests performed during structure learning using the PC-algorithm. The default value is 0.05.
Declaration
Swift
public func getSignificanceLevel() throws -> DoubleReturn Value
A number between 0 and 1.
-
Learns the conditional probability tables from data using the EM algorithm.
Declaration
Swift
public func learnTables() throws -
Learns the conditional probability tables of the class nodes, from which the domain is created, from data using the EM algorithm.
Declaration
Swift
public func learnClassTables() throws -
Sets the log-likelihood tolerance for this
Domain.Declaration
Swift
public func setLogLikelihoodTolerance(_ tolerance: Double) throws -
Returns the log-likelihood tolerance for this
Domain.Declaration
Swift
public func getLogLikelihoodTolerance() throws -> Double -
Sets the maximum number of iterations allowed for the EM algorithm. No value (
nil) specifies an unbounded number of iterations.Declaration
Swift
public func setMaxNumberOfEMIterations(_ m: Int?) throws -
Returns the maximum number of iterations allowed for the EM algorithm.
Declaration
Swift
public func getMaxNumberOfEMIterations() throws -> Int? -
Triangulates a DBN runtime
Domainfor exact inference.Declaration
Swift
public func triangulateDBN(_ tm: TriangulationMethod) throwsParameters
tmthe TriangulationMethod to use.
-
Triangulates a DBN runtime
Domainfor approximate inference. Boyen-Koller approximate inference is applied to the interfaces between the time slices of the time window.Declaration
Swift
public func triangulateDBNForBK(_ tm: TriangulationMethod) throwsParameters
tmthe TriangulationMethod to use.
-
Tests whether this
Domainis triangulated for Boyen-Koller approximate inference.Declaration
Swift
public func isTriangulatedForBK() throws -> Bool -
Slides the time window of this DBN
deltasteps into the future. ThisDomainmust have been produced byDomain.init(Class,Int), and it must have been triangulated usingDomain.triangulateDBN(TriangulationMethod).Declaration
Swift
public func moveDBNWindow(_ delta: Int) throwsParameters
deltathe number of time steps to slide the time window (this must be a positive number).
-
Returns the total number of time steps that the time window of this DBN runtime domain has been moved.
Declaration
Swift
public func getDBNWindowOffset() throws -> Int -
Moves the time window of this DBN back to its initial position, and removes all evidence. This
Domainmust have been produced byDomain.init(Class,Int), and it must have been triangulated usingDomain.triangulateDBN(TriangulationMethod).Declaration
Swift
public func initializeDBNWindow() throws -
Computes predictions for
numberOfTimePointstime slices beyond the current time window. ThisDomainmust have been produced byDomain.init(Class,Int), and it must have been triangulated usingDomain.triangulateDBN(TriangulationMethod). The predictions are accessed usingNode.getPredictedBelief(Int,Int),Node.getPredictedMean(Int),Node.getPredictedVariance(Int), andNode.getPredictedValue(Int)`.Declaration
Swift
public func computeDBNPredictions(_ numberOfTimePoints: Int) throwsParameters
numberOfTimePointsthe number of time slices to compute predictions for (this must be a positive number).
-
Adds the specified range of rows of the data set to this
Domainas cases.Declaration
Swift
public func addCases(_ dataSet: DataSet, start: Int, count: Int) throwsParameters
startthe index of the first row to add
countthe number of rows to add.
-
Adds all rows of the data set to this
Domainas cases.Declaration
Swift
public func addCases(_ dataSet: DataSet) throws -
Sets the level of concurrency. The level of concurrency specifies the maximum number of threads to create when performing a specific table operation. Setting the level of concurrency to 1 will cause all table operations to be performed sequentially. The initial parameter value is 1.
Declaration
Swift
public func setConcurrencyLevel(_ level: Int) throwsParameters
levelthe level of concurrency.
-
Sets the grain size parameter. The grain size parameter specifies a lower limit of the tasks to be performed by each thread. The size of a task is approximately equal to the number of floating-point operations needed to perform the task (e.g., the number of elements to sum when performing a marginalization task).
The initial value of the grain size parameter is 10000.
Declaration
Swift
public func setGrainSize(_ size: Int) throwsParameters
sizethe grain size.
-
Gets the current level of concurrency.
See also
Domain.setConcurrencyLevelDeclaration
Swift
public func getConcurrencyLevel() throws -> IntReturn Value
A positive integer.
-
Returns the current value of the grain size parameter.
Declaration
Swift
public func getGrainSize() throws -> IntReturn Value
A positive integer.
-
Sets the number of threads to be created by the EM algorithm. The EM algorithm exploits concurrency by partitioning the set of cases into subsets of approximately equal size. Each subset is then processed by a thread that has a copy of the (compiled) domain, enabling the threads to perform inference in parallel.
Setting this parameter to 1 causes the EM algorithm to execute single-threaded. The initial value of this parameter is 1.
Declaration
Swift
public func setEMConcurrencyLevel(_ level: Int) throwsParameters
levelthe level of concurrency (must be a positive number).
-
Returns the number of threads to be created by the EM algorithm.
See also
Domain.setEMConcurrencyLevelDeclaration
Swift
public func getEMConcurrencyLevel() throws -> Int
Domain Class Reference