CompileNetwork {RNetica} | R Documentation |
Before Netica performs inference in a network, it needs to compile the
network. This process consists of building a junction tree and
conditional probability tables for the nodes of that tree. The
function CompileNetwork()
compiles the network and
UncompileNetwork()
undoes the compilation and frees the
associated memory.
CompileNetwork(net) UncompileNetwork(net) is.NetworkCompiled(net)
net |
An active |
Usually Bayesian network projects operate in two phases. In the construction phase, new nodes are added to the network, new connections made and conditional probability tables are set.
In the inference phase, findings are added to nodes and other nodes are queried about their current conditional probability tables.
The functions CompileNetowrk()
and UncompileNetwork()
move the networks between the two phases. The documentation for
EliminationOrder()
and JunctionTreeReport()
provide more details about the compilation process. The function
NetworkCompiledSize()
provides information about the
amount of storage used by the compiled network, but only after the
network is compiled.
The function is.NetworkCompiled()
tests to see if a network is
compiled or not.
The NeticaBN
object net
is returned invisibly.
I'm currently observing a bug that occurs under Windows if not all of the nodes have their CPTs set. Under Linux the function exhibits the expected behavior: It generates a warning about the unset CPTs and enters a uniform distribution for each one. Under Windows it reports the warning, but then generates an error "GetError_ns: deleted or damage report_ns passed". It is unclear if this a problem in Netica or RNetica.
To work around, simply set all tables before compiling.
Calling NetworkCompiledSize()
on an uncompiled network
produces, an error, but also the sensible value of -1
. The
function is.NetworkCompiled()
calls the same internal function
as NetworkCompiledSize
, but clears the error. This means it
also clears any other errors that might be lurking in the system (see
ReportErrors()
).
I think calling CompileNetwork()
twice on
the same network is harmless. Adding a node to a network will
automatically uncompile it.
Russell Almond
http://norsys.com/onLineAPIManual/index.html: CompileNet_bn(), UncompileNet_bn(), SizeCompiledNet_bn(),
NeticaBN
, HasNodeTable()
,
NodeFinding()
, NodeBeliefs()
,
EliminationOrder()
, JunctionTreeReport()
,
JointProbability()
,
MostProbableConfig()
,
FindingsProbability()
sess <- NeticaSession() startSession(sess) irt5 <- ReadNetworks(file.path(library(help="RNetica")$path, "sampleNets","IRT5.dne"), session=sess) stopifnot (!is.NetworkCompiled(irt5)) CompileNetwork(irt5) ## Ready to enter findings stopifnot (is.NetworkCompiled(irt5)) UncompileNetwork(irt5) ## Ready to add more nodes stopifnot (!is.NetworkCompiled(irt5)) DeleteNetwork(irt5) stopSession(sess)