B. Basic Netica Operation | Copyright © 2024 Norsys Software Corp. |
2. Building Net Structure In the tutorial's Introduction, we saw how to use a Bayes net that had previously been built for you. In this tutorial you will learn the steps for building your very own Bayes net. We concentrate on the basics of analyzing a problem and deriving its causal structure. This will translate into the nodes and links between the nodes that go into a Bayes net. In next tutorial we will concentrate on how to define the probabilistic relationships between the nodes that have been linked up. The first step in creating a net is clicking on the menu item: File->New Network. Netica will create an empty network window for you. We recommend using the 'Save As' command right away in order to name and save your net. 2.1 Creating Nodes The next step is deciding what variables will be modeled by the net. You then simply create one node per variable and place them wherever you wish in the net window, although in general, you will find it works out best to place related nodes together. If there is a causal relationship between two nodes, the convention is to place the causing node (the parent) above the caused node (the child). Nodes that are at the top of the net are typically reserved for initial causes, with subsequently caused or influenced events occurring progressively lower down. Final Observable variables are usually placed lower down in the net. You create a nature node in any of these ways:
After this, a clear ellipse icon will appear in the net window, indicating that a node is ready for placement. Simply move the mouse to where you want that node to be placed and click again. You can of course move it later by simply dragging it to anywhere on the net window. Now that the node exists, you must define its properties. Double-click on the node to raise the node dialog box: ![]() 2.1.1 Names and Titles All the nodes in a net must have unique names. The names are limited to 30 or fewer characters. The first character must be a letter. The remaining characters may be letters, digits (0-9), or the underscore ('_'). Names cannot have spaces or any punctuation or other characters. Node names are used in reports and other size restricted settings. When first created, nodes are given a unique default name. You can change this to any valid name that has not already been taken by some node in the net. Titles do not have the same restrictions that names have; they can be any length and contain any characters. 2.1.2 Kind The majority of nodes in your net will typically be nature nodes, meaning they model reality as opposed to extra-reality concepts like values or decisions. Constant nodes can be thought of as tuning parameters; they are typically held constant, but can be changed by the designer to influence the net's behavior. Assuming we are creating a nature node, a key decision to be made is declaring whether the node can take on an infinite or discrete range of values or states. We will explore how to make this declaration in the following sections. 2.1.3 Discrete vs. ContinuousRecall that each (nature) node in a Bayes net stands for a feature of the world being modeled. This is a property of something that can vary. The variance can be over a finite set of states, or a virtually infinite set of values. Often Bayes net builders use the terms 'node' and 'variable' interchangeably. Variables can be of two varieties, discrete, meaning representing a finite number of possible values (e.g., hot/medium/cold, big/small, 1/2/3, etc.), and, continuous, meaning representing an infinite range of possible values (e.g., 0.5-3.4). Dealing with an infinite range of values requires special consideration for Bayes net theory. This is because many of the algorithms so far devised work best when a finite number of parent states are considered. Tables are by nature suited to representing a discrete number of things, and if you do not use tables internally, you must use equations and have a very sophisticated symbolic mathematical engine for computing the constraints amongst all the equations. Netica can handle continuous variables without difficulty. However, because all of its probabilistic inference is done with discrete tables, internally it must convert the continuous variables to discrete quantities before any probabilistic inference can be done. The node dialog box has a Discrete selector, which allows you to choose whether the node represents a continuous or a discrete variable. Choose whichever state is appropriate for that particular node. It should be noted that even though a variable behaves in one dominant fashion, as discrete or continuous, it is common to want to treat it as though it behaved differently. This is easy to do with Netica, and thus you are not committed to treating a continuous variable as solely continuous, nor the reverse. For instance, take a battery's voltage. You might normally consider voltage as a continuous quantity. However, at times, it may be useful to discretize the voltage into ranges of values. The battery's charge could be considered weak, medium, or strong, depending on whether its voltage falls in the ranges, 0-0.5, 0.5-5, or 5.0 and higher. Likewise, there are times when a discrete variable, say one that is True or False, can be conveniently associated with numeric values. Say True is a voltage of 3.0, while False is 2.0. To learn how to assign a continuous variable a set of discrete ranges, or to give the states of a discrete variable numbers, see "Node Ranges" in the on-screen help system. Note: A utility node must be continuous and a decision node must be discrete. 2.1.4 States By default, a node is created with two states, True and False. You can give the states other names by first selecting the desired state, and then entering its name in the window. The "Value" field is for associating a real numbered value with the selected state. The "New" button is for adding a state. If you have many states (names and/or values) to enter, or you wish to delete states, you will want to use the Multi-Purpose box. To set state names, select "States". To select state values, select "Ranges". See the on-screen help for the line syntax accepted by the Multi-Purpose box. 2.1.5 Description and Other Properties Nodes can be given many useful documentation strings, including a Description or Comment field, an Author field, and even arbitrary name-value pairs. Lookup "Multi-Purpose Box" in the on-screen help for details. 2.1.6 Rapid Node Creation If you need to create many nodes of a certain type, simply double-click on the tool bar icon for that type of node: ![]() ![]() ![]() This will put Netica in "rapid node creation mode". Once in this mode, each time you click in the net window, a node of that type will be created at that location. To leave "rapid node creation mode", simply single-click on any button in the tool bar. 2.1.7 Creating Nodes Automatically From Case Files Now that you have learned how to create nodes manually, you will be pleased to learn that Netica can also create nodes directly from data sets. This is a great time-saving feature, provided that you have a well defined data set. To make use of this feature, the dataset must be in Case File Format. 2.2 Adding Links Once you have created two or more nodes, you may begin linking them together. You create a link in any of these ways:
Rapid Link Creation Mode: Just as with "rapid node creation mode", there
is a convenient option in Netica that allows you to enter "rapid link creation mode"
to save you extra mouse clicks. To enter this mode, simply double-click on the
2.3 Moving Nodes and AutoGrid To move a node, click down on it, drag it to its new position, and then release the mouse button. If you wish to move a set of nodes, drag a box around the set of nodes to select them, then click down on one of them and drag the entire set to the new desired location. You can add to a previously selected set by holding down the ctrl or shift keys while selecting, which is the standard way that the File Managers in Microsoft Windows or Macintosh OS operate. Therefore, if you are familiar with those systems, you will find selecting and moving objects in Netica very natural. When you move nodes, any links they possess will automatically move along with them. AutoGrid: There is an underlying, invisible grid of positions in the net window, and when you add or move a node, the node will be shifted slightly so that its center is directly over one of these grid positions, providing the AutoGrid is turned on. This allows you to quickly draw a network whose nodes are perfectly aligned, and with links running perfectly horizontal or perfectly vertical. To turn AutoGrid off or on, toggle Layout->AutoGrid. If you want to change the spacing of the grid, to make it finer or courser, choose Layout->Grid-Spacing, and a dialog box will appear allowing you to make the setting. Nudging: Sometimes it is useful to be able to move a node, or set of nodes, a small predictable amount. You can use the arrow keys to do this nudging. Simply select the nodes you wish to move, and then press the key with the arrow in the direction you want them to move. The distance they will be moved with each press of the key is the grid spacing (providing the AutoGrid is turned on), so you can adjust this amount using the Layout->Grid-Spacing menu entry. If the AutoGrid is turned off, then with each press of the key they will be moved the smallest perceptible amount. 2.4 Selecting Nodes and Links Selection is an important operation in Netica, since many operations are done by first selecting one or more items, and then choosing an operation to perform upon them. Netica offers many useful operations for dealing with selected objects, including creating, saving, and restoring them. Netica indicates a selected object by drawing it hilited or with negative colors. 2.4.1 Nodes Select a node by clicking once on it. To select a group of nodes, click down on the background and then drag the selection rectangle to include at least a part of each of them. To unselect all the nodes currently selected, just click once on the background within the window. Choosing Edit->Select-All (or typing CTRL+A, as Windows convention) will select all the nodes in the network. Modifying: When you select new nodes, any nodes that were previously selected will become unselected, unless you hold down the CTRL or SHIFT key while clicking or dragging. In that case the selected status of the given node(s) will be reversed. This allows you to add to, or remove from, the current collection of selected nodes. Reversing: To reverse the selection so that it includes only the nodes currently not selected, hold down the SHIFT key while choosing Edit->Select-All. (In the next release of Netica, a separate menu item, "Edit->Select Nodes->Invert Selection", is provided for this.) From Text: Edit->"Select Copied Nodes" will select all the nodes whose name (not title) appears in the text currently copied to the clipboard. For example, if your word processing program has a document that mentions several nodes by name, you could select that text, copy it, and then do "Select Copied Nodes" in Netica to select them. Save/Restore: You can save the current selection as text with Report-> "List Selected Nodes", and then restore it using Edit->"Select Copied Nodes". Doesn't Work: If you are selecting belief-bar or belief meter style nodes, then you should click on the title (or name) of the node, since clicking elsewhere may be interpreted as entering a finding (in which case the node will be darkened instead of drawn with negative colors). 2.4.2 Links To select a link, left click on it. It will become drawn in hilited outline form. Once again, if the CTRL key is held down while clicking, it will reverse the selection status of only the link being clicked on, which can be used to add or remove from your collection of selected links. Links cannot be selected by dragging the selection rectangle over them. Nodes and links cannot both be selected at the same time, so whenever you select links, any nodes that are selected will become unselected, and vice-versa. 2.5 Undoing & Redoing While building or changing the network you can undo the last operation by any of:
You can undo as many operations as Netica has remembered, which varies, depending on the amount of memory required to keep track of previous states. Netica will always remember at least four operations. When you save a net, Netica clears its memory; therefore, you can no longer undo operations prior to the save. When the Edit->Undo menu item or toolbar button turns dim, you have run out of undos. When the Edit->Redo menu item or toolbar button turns dim, you have restored all the operations previously undone. The operations done in each window are remembered separately, so if you return to window A after working in another window for awhile, you can still undo operations previously performed in window A. Become familiar and experienced early with Undo and Redo, as they are very useful and time-saving operations. 2.6 Reshaping a Link When a network diagram becomes large it can be very difficult to view if all the links between the nodes are straight lines. Even small diagrams can sometimes be made more legible by choosing suitable paths for the links. Adding Bends: To shape a link, first click once on the link to select it. The link will be drawn with the hilite color surrounding it. Then click down again on the selected link, and drag the cursor. A bend will be placed in the link and dragged by the cursor. You can repeat this to add as many bends as you wish. Try this to see how easy and natural it is. Moving Bends: To move the position of a bend, first select the link as before. The link will become hilited and there will be a square box at each of its bends, and at its two endpoints. To move a bend or an endpoint, click down in its hilited box, drag it to its new position, and then release the mouse button. Moving one bend into another, or into an endpoint, will combine them, which can be used to remove bends. Try moving the bend you created above. Now try merging it into one of the endpoints to delete it. Moving Ends: There are some special considerations when moving the endpoints of a link. The arrow end of a link cannot be dragged very far from the node it points to (the arrow will just bump against an invisible barrier). This prevents the creation of misleading or confusing diagrams (since the link is still considered to be connected to the node). If you drag the non-arrow end of a link too far from its parent node the link will become "disconnected" from that node. You can tell this has happened because the name of the link suddenly appears at the endpoint you have moved. See the on-screen help for more on this subject. AutoGrid and Nudging: Just as with nodes, the AutoGrid feature applies to links, allowing you to make very nicely aligned and positioned links. 2.7 Saving and Restoring a Network Saving: To save the active network to a file, choose File->Save As
or click on Saving with or without Findings: If there are any findings (evidence) entered in the net, they will be saved as well. If you don't want this, select Network->"Remove Findings" before saving. File Format: The network gets saved to a file consisting only of ASCII text, so it may easily be transferred from one type of computer to another (e.g. from Windows to Unix to Macintosh) or sent by email. You may examine and modify the file with a text editor. It is in the DNET-1 file format. Restoring: To read a previously saved net and make it the active
network, choose File->Open... or click on Try saving and restoring your current net. We recommend that you get into the habit of creating numerous "checkpoint" versions of your net, as you construct them, in case you wish to return to an earlier version that cannot be restored via the "Undo" feature. Also, you can often save much time by editing someone else's previously built net (within Netica, or by using a text editor on the .dne file) instead of creating your own from scratch. Many users even utilize programs to automatically construct a .dne file, which will then be readable by Netica. 2.8 Deleting Nodes and Links 2.8.1 Nodes To delete a node or nodes, first select each particular node, and then do one of:
This will remove the nodes and all links from other nodes going to them. Links going from them to their child nodes will be disconnected just before the deletion. These disconnected links will be selected after the nodes are removed, so you can easily delete them as well by just pressing DELETE a second time. Try constructing a network with a chain of three nodes and then delete the middle node and the disconnected links that subsequently form. If you wish to remove the nodes, but maintain the global relationship of the remaining nodes (i.e., the joint distribution), you should absorb [to be linked...] the nodes. This is an extremely powerful operation that can be used to simplify a network, if you find for whatever reason that you have too many nodes. 2.8.2 Links To delete a link, click on it to select it, and then perform a deletion, as above. To delete a series of links, select them all and then perform a deletion. When a link is deleted, the conditional probabilities of the child node are collapsed to eliminate their dependence on that parent, as if the parent took on its first state. This may or may not be desirable, so you may want to revisit the former child's conditional probability tables after performing such a step. When a link is deleted the parent node is not affected in any way. 2.9 Net Resizing and Zooming When a network diagram becomes large, it is handy to be able to zoom out to see more of it in the window at once. In addition, when preparing your nets for graphic presentations, you may want to size them exactly. Netica offers several convenient means to adjust a net's size. The full set of zoom commands that are available from the Window->Zoom menu or the keyboard are as follows:
Experiment with each zoom operation, as they are all quite handy. Nodes: Nodes within a network may be resized by adjusting their text font. Select menu item Style->Font to raise a full-featured font selection dialog. ![]() Note: The particular magnification used to display a network, or its nodes, does not influence any operation performed on the network. |
Return to Tutorial Home |