Continuous inference

<< Click to Display Table of Contents >>

Navigation:  Using SMILE Wrappers > Continuous models >

Continuous inference

To run the inference in continuous model, use Network.updateBeliefs; the same method which is used in discrete networks.

To set evidence in an equation node, use Network.setContEvidence. In the snippet below we are assuming that evidenceNodeHandle is the handle of the equation node.

Java:

net.setContEvidence(evidenceNodeHandle, 1.5);

Python:

net.set_cont_evidence(evidenceNodeHandle, 1.5)

R:

net$setContEvidence(evidenceNodeHandle, 1.5)

C#:

net.SetContEvidence(evidenceNodeHandle, 1.5);

To retrieve evidence from continuous node, use Network.getContEvidence.

The inference in continuous networks is based on stochastic sampling when there is no evidence in the network, or the evidence is specified only for nodes without parents. Otherwise, the inference is performed on a temporary discrete network, derived from the original continuous model. The definitions for the temporary discrete nodes are derived from the discretization intervals defined in each continuous node. In addition to Network.setSampleCount, stochastic sampling can be controlled at the network level by setting the discretization sample count with Network.setDiscretizationSampleCount. Large number of samples provides better approximation of the solution to the set of equations, which continuous network represents, but requires more time to complete.

Both types of inference algorithm use the lower and upper bounds defined for each equation node. To set the bounds, use Network.setNodeEquationBounds method. Stochastic sampling can reject a sample when its value falls outside of the bounds defined for the node. You can control this behavior by Network.setOutlierRejectionEnabled. By default, outlier rejection is disabled.

To set node's discretization intervals, use Network.setNodeEquationDiscretization. The method accepts an array of DiscretizationInterval objects intervals as its argument. Each interval is defined by its optional identifier (not used for inference) and an upper bound. The lower bound of the interval with index j is defined by upper interval of the interval with index j-1. The lower bound of the first interval is defined by the lower bound defined for the node with a Network.setNodeEquationBounds call.

Discretization intervals are used to obtain CPTs for the temporary discrete network. The CPTs are calculated by drawing a number of samples specified at the network level for each CPT column. The size of the discretized CPT is a product of the number of node intervals and parent node intervals. Note that this may lead to excessive memory use when the node has many parents.

The results of the inference in a continuous model can be either samples or discretized beliefs, depending on the inference algorithm:

sampling algorithm outputs samples for each node. Network.getNodeValue will return an array of samples and Network.getNodeSampleStats returns an array with simple statistics for the sample set (mean, standard deviation, minimum and maximum. Network.isValueDiscretized returns false.

discretizing algorithm outputs probability distribution over discretization intervals. Network.getNodeValue returns this distribution. Network.isValueDiscretized returns true.