NNWarehouse-class | R Documentation |
"NNWarehouse"
This is a container for node objects, which are instances of the
Pnode
class. If a requested node is not
already built, it can be built from the description found in the
warehouse. In implements the Warehouse
protocol.
The NNWarehouse
generally works with a paired
BNWarehouse
which supplies the network. It assumes that
the referenced network already exists or has been loaded from a file.
If the node already exists in the network, it simply returns it. If
not, it creates it using the metadata in the manifest.
The manifest is an object of type data.frame
where
the columns have the values show below. The key is the
pair of columns (“Model”, “NodeName”), with each pair
identifying a set of rows correpsonding to the possible states of the
node. The name argument to
WarehouseData
should be a character vector of length 2 with the
first component corresonding to the network name and the second to the
node name; it will return a data.frame
with multiple rows.
Some of the fields of the manifest data apply to the whole node. In these fields, the value in the first row is used and the rest are ignored.
A integer giving the number of states for a discrete variable or the discritzation of a continuous one. The number of rows of the manifest data for this node should match this.
A logical value telling whether or not the node should be regarded as continuous.
This is a longer unconstrained name for the node.
This is a longer string describing the node.
This is a comma separated list of tags identifying
sets to which the node belongs. See
PnodeLabels
.
These fields are repeated for each of the states in the node, as they are different for each state. The “StateName” field is required and must be unique for each row.
The name of the state, this should follow the Netica IDname conventions.
This is a longer unconstrained name for the state.
This is a longer string describing the state.
Additionally, the following field is used only for discrete nodes:
This is a numeric value assigned to the state. This value is used when calculating the node expected value.
The StateValue plays two important roles. First, when used with the
PnodeEAP
and PnodeSD
functions, it is the value assigned to the node. Second, when
constructing CPTs using the DiBello framework, it is used at the
effective thetas. See PnodeParentTvals
and
PnodeStateValues
Continuous nodes in Netica are handled by breaking the interval up
into pieces. This is the function
PnodeStateBounds
. Note that the bounds should
be either monotonically increasing or decreasing and that the lower
bound for one category should match lower bound for the next to within
a tolerance of .002. The values Inf
and -Inf
can be
used where appropriate.
This is a numeric value giving the lower bound for the range for the discritization of the node.
This is a numeric value giving the upper bound for the range for the
Objects can be using the constructor NNWarehouse
.
This class is a subclass of PnodeWarehouse
in the
Peanut-package
.
This is a reference object and typically there is only one instance per project.
manifest
:A data frame that gives details of how to build the nodes.
session
:Object of class
NeticaSession
, which is a pointer back to
the Netica user space.
key
:A character vector of length two, which gives the name of the fields in the manifest which which identify the network and variable names.
prefix
:Object of class "character"
which is
used as a prefix if the name needs to be mangled to fit Netica
IDname conventions.
Class "PnodeWarehouse"
, directly.
For all of these methods, the name
argument is expected to be a
vector of length 2 with the first component specifying the network and
the second the node.
signature(warehouse =
"NNWarehouse", name = "character", restoreOnly)
. In this case
the name is
expected to be a vector of length 2 with the first component
identifying the network and the second the node within the
network. This finds a node with the appropriate name in the
referenced network. If one does not exist,
it is created with the properities specified in the manifest.
signature(warehouse = "NNWarehouse",
name="character")
: Fetches the node if it already exists, or
returns NULL
if it does not.
signature(warehouse = "NNWarehouse",
restoreOnly)
: Makes a new node, calling
MakePnode.NeticaNode
. The restoreOnly
argument is ignored.
signature(warehouse = "NNWarehouse")
:
If necessary, mangles a node name to follow the Netica
IDname conventions.
signature(warehouse = "NNWarehouse")
:
Removes prebuilt objects from the warehouse.
signature(warehouse = "NNWarehouse")
:
Checks to see if a node name follows the Netica
IDname conventions.
signature(obj = "NNWarehouse")
:
Returns true.
signature(warehouse = "NNWarehouse")
: Checks
an object to see if it is a valid Netica Node.
signature(warehouse = "NNWarehouse", obj
= "NeticaNode")
: Makes a copy of a node.
signature(warehouse = "NNWarehouse")
:
Returns the hunk of manifest for a single node.
signature(warehouse = "NNWarehouse")
:
Deletes the node.
signature(warehouse =
"NNWarehouse")
: Returns a list of all nodes which have already
been built.
signature(warehouse =
"NNWarehouse")
: Returns the current warehous manifest
signature(warehouse =
"NNWarehouse", value = "data.frame")
: sets the manifest
signature(warehouse = "NNWarehouse", obj
= "ANY")
: Does nothing. Saving is done at the netowrk level.
Class "PnodeWarehouse"
, directly.
The test for matching upper and lower bounds is perhaps too strict. In particular, if the upper and lower bounds mismatch by the least significant digit (e.g., a rounding difference) they will not match. This is a frequent cause of errors.
Russell Almond
The following is a Google sheet where an example node manifest can be
found on the nodes
tab.
https://docs.google.com/spreadsheets/d/1SiHQTLBNHQ-FUPnNzf9jPm9ifUG-c8f_6ljOrEcdl9M/
In Peanut Package:
Warehouse
, WarehouseManifest
,
BuildNodeManifest
Implementation in the PNetica
package:
NNWarehouse
,
MakePnode.NeticaNode
sess <- NeticaSession()
startSession(sess)
## BNWarehouse is the PNetica Net Warehouse.
## This provides an example network manifest.
netman1 <- read.csv(system.file("auxdata", "Mini-PP-Nets.csv",
package="Peanut"),
row.names=1, stringsAsFactors=FALSE)
Nethouse <- BNWarehouse(manifest=netman1,session=sess,key="Name")
nodeman1 <- read.csv(system.file("auxdata", "Mini-PP-Nodes.csv",
package="Peanut"),
row.names=1,stringsAsFactors=FALSE)
Nodehouse <- NNWarehouse(manifest=nodeman1,
key=c("Model","NodeName"),
session=sess)
CM <- WarehouseSupply(Nethouse,"miniPP_CM")
WarehouseSupply(Nethouse,"PPdurAttEM")
WarehouseData(Nodehouse,c("miniPP_CM","Physics"))
WarehouseSupply(Nodehouse,c("miniPP_CM","Physics"))
WarehouseData(Nodehouse,c("PPdurAttEM","Attempts"))
WarehouseSupply(Nodehouse,c("PPdurAttEM","Attempts"))
WarehouseData(Nodehouse,c("PPdurAttEM","Duration"))
WarehouseSupply(Nodehouse,c("PPdurAttEM","Duration"))
WarehouseFree(Nethouse,"miniPP_CM")
WarehouseFree(Nethouse,"PPdurAttEM")
stopSession(sess)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.