Code: Select all
import pysmile
import pysmile_license
net = pysmile.Network()
e = self.create_cpt_node(net,
    "Economy", "State of the economy",
    ["Up","Flat","Down"], 
    160, 40)
s = self.create_cpt_node(net,
    "Success", "Success of the venture",
    ["Success","Failure"], 
    60, 40)
f = self.create_cpt_node(net,
    "Forecast", "Expert forecast",
    ["Good","Moderate","Poor"], 
    110, 140)
def create_cpt_node(self, net, id, name, outcomes, x_pos, y_pos):
    handle = net.add_node(pysmile.NodeType.CPT, id)
    net.set_node_name(handle, name)
    net.set_node_position(handle, x_pos, y_pos, 85, 55)
    initial_outcome_count = net.get_outcome_count(handle)
    for i in range(0, initial_outcome_count):
        net.set_outcome_id(handle, i, outcomes[i])
    for i in range(initial_outcome_count, len(outcomes)):
        net.add_outcome(handle, outcomes[i])
    return handle
    net.add_arc(e, s)
net.add_arc(s, f)
net.add_arc("Economy", "Forecast")
successDef = [
    0.3, # P(Success=S|Economy=U)
    0.7, # P(Success=F|Economy=U)
    0.2, # P(Success=S|Economy=F)
    0.8, # P(Success=F|Economy=F)
    0.1, # P(Success=S|Economy=D)
    0.9  # P(Success=F|Economy=D)
]
net.set_node_definition(s, successDef)
print("Posteriors with no evidence set:")
net.update_beliefs()
self.print_all_posteriors(net)i want to run this code but i get this error why ?
Code: Select all
      4 net = pysmile.Network()
      5 
----> 6 e = self.create_cpt_node(net,
      7 
      8     "Economy", "State of the economy",
NameError: name 'self' is not definedthank you