node backgorund color and node discretization

The engine.
Post Reply
EAly
Posts: 21
Joined: Tue Apr 14, 2020 1:16 pm

node backgorund color and node discretization

Post by EAly »

Hello,

I'm new to GeNie and smile and I'm using the Pysmile wrapper, I have a couple of questions:

1. the following method

Code: Select all

net.set_node_bg_color()
is supposed to take two arguments; node handle or id, and an int representing the colour. So how colours are represented as int in smile? I tried the hex code (e.g. FF0000) of colours and the RGB (e.g. 25500) numbers but they both give me an error.

2. when building continues or hybrid models, I use a custom function to uniformly discretize an equation node based on its boundaries (as demonstrated in the wrappers guide) but whenever I check if node value is discretized using the method

Code: Select all

net.is_value_discretized(handle)
, I get a False value. So I'm not quite sure how this works or if I'm doing something wrong?
Also, is it possible to discretize a node using non-uniform intervals? and what the equivalent of the "Rediscretize" and the "Elicitate" tabs in the Pysmile wrapper?

Thanks in advance for your help
piotr [BayesFusion]
Site Admin
Posts: 60
Joined: Mon Nov 06, 2017 6:41 pm

Re: node backgorund color and node discretization

Post by piotr [BayesFusion] »

Ad 1

Node background color could be setted this way:

Code: Select all

net.set_node_bg_color(handle, 0x0000ff)
net.set_node_bg_color(handle, 0x123456)
Hexadecimal numbers seem to be the easiest way when it comes to color reading, however, SMILE was initially written in the Windows environment, so color format is reversed (BGR). In the future we will add a more intuitive way to set colors.

Ad 2

Equation Node may be discretized when one of its discrete descendants has evidence. You can check it with this code:

Code: Select all

net = pysmile.Network()
cpt = net.add_node(pysmile.NodeType.CPT, "cpt_node")
eq = net.add_node(pysmile.NodeType.EQUATION, "eq_node")
net.set_node_equation(eq, "eq_node=Normal(0,1)")
net.set_node_equation_bounds(eq, -4, 4)
disc_intervals = [pysmile.DiscretizationInterval('a', 1), pysmile.DiscretizationInterval('b', 3)]
net.set_node_equation_discretization(eq, disc_intervals)
net.add_arc(eq, cpt)
net.set_evidence(cpt, 0)
net.update_beliefs()
net.is_value_discretized(eq)
Also, you can set continous evidence of Equation Node with method set_cont_evidence:
https://support.bayesfusion.com/docs/Wr ... rence.html
EAly
Posts: 21
Joined: Tue Apr 14, 2020 1:16 pm

Re: node backgorund color and node discretization

Post by EAly »

Thanks Piotr for your reply and explanation!

I just need one more clarification, in your reply you used two discretization intervals ('a,1' and 'b,3'), however, the actual created intervals have the bounds of [1, 4], i.e. the 3 is ignored and only 1 is used as a middle value between the bounds [-4, 4]?
Post Reply