I can not import pysmile in my mac.
-
- Posts: 34
- Joined: Thu Mar 19, 2020 11:49 am
I can not import pysmile in my mac.
Dear sir or madam,
I can download "GeNIe" and pip install the "pysmile" package, and I have put the license of pysmile in the file I use it to code in python. but it shows SMILEEncodeError and print repr(a) has invalid syntax error. could you please help me solve this problem? I put the "error" in the attachments.
(I can import pymsile well when I use my previous pc which uses windows system, but my pc has some problems now, so I use my MAC pc to continue my study, but I can import pysmile well)
kind regards!
Yajie
I can download "GeNIe" and pip install the "pysmile" package, and I have put the license of pysmile in the file I use it to code in python. but it shows SMILEEncodeError and print repr(a) has invalid syntax error. could you please help me solve this problem? I put the "error" in the attachments.
(I can import pymsile well when I use my previous pc which uses windows system, but my pc has some problems now, so I use my MAC pc to continue my study, but I can import pysmile well)
kind regards!
Yajie
- Attachments
-
- Screen Shot 2020-07-02 at 11.28.48.png (195.05 KiB) Viewed 7637 times
-
- Site Admin
- Posts: 61
- Joined: Mon Nov 06, 2017 6:41 pm
Re: I can not import pysmile in my mac.
Package installed by pip is not BayesFusion's PySMILE. To use PySMILE, you need to uninstall pysmile installed by pip.
Download PySMILE from our website - https://download.bayesfusion.com/ and uncompress archive in your project directory.
Note that PySMILE works with official Python binaries (https://www.python.org/downloads/). Python binaries installed by Homebrew (macOS) are not supported yet.
Code: Select all
pip uninstall pysmile
Download PySMILE from our website - https://download.bayesfusion.com/ and uncompress archive in your project directory.
Note that PySMILE works with official Python binaries (https://www.python.org/downloads/). Python binaries installed by Homebrew (macOS) are not supported yet.
-
- Posts: 34
- Joined: Thu Mar 19, 2020 11:49 am
psmile to code dynamic Bayesian network
I download and unpackage the document package into my coding file. but it seems can not work. I try to use my windows system computer to finish my dynamic bayesian network (DBN). i have another questions need your help.
for me, i plan to create the DBN in genie, and load this dbn.xdsl in python, then make inference for records in python. but it seems i can not connect all arcs for all nodes in my network, so i can not continue my inference in python. i have to sole my DBN create problem in genie or python by using pysmile.
as you can see the nodes in the attachment, i put part of my network in the network, actually the nodes like Events1 has 10. the nodes like S1 has more than 40. when i try to connect temporal arcs among S1 type and Events1 type nodes, the GeNIe will shut down. i can not connect all arcs for my network. so i try to code my DBN in python by using pysmile.
but the Tutorial 6 you provided shown that I have to creates a dynamic bayesian network first by using create_cpt, set_node_temporal_type, and using nodesname_def to edit the cpt of nodes. i have too much ndoes in my DBN. some nodes' cpt has 560000 cells, if i edit them manually, it is too difficult and waste too much. I usually create DBN in Genie, the initial cpt and final cpt can be calculated by genie easily. Do you have some easier way to create DBN?
for me, i plan to create the DBN in genie, and load this dbn.xdsl in python, then make inference for records in python. but it seems i can not connect all arcs for all nodes in my network, so i can not continue my inference in python. i have to sole my DBN create problem in genie or python by using pysmile.
as you can see the nodes in the attachment, i put part of my network in the network, actually the nodes like Events1 has 10. the nodes like S1 has more than 40. when i try to connect temporal arcs among S1 type and Events1 type nodes, the GeNIe will shut down. i can not connect all arcs for my network. so i try to code my DBN in python by using pysmile.
but the Tutorial 6 you provided shown that I have to creates a dynamic bayesian network first by using create_cpt, set_node_temporal_type, and using nodesname_def to edit the cpt of nodes. i have too much ndoes in my DBN. some nodes' cpt has 560000 cells, if i edit them manually, it is too difficult and waste too much. I usually create DBN in Genie, the initial cpt and final cpt can be calculated by genie easily. Do you have some easier way to create DBN?
- Attachments
-
- Example.xdsl
- (375.39 KiB) Downloaded 368 times
-
- Site Admin
- Posts: 61
- Joined: Mon Nov 06, 2017 6:41 pm
Re: I can not import pysmile in my mac.
I assume you managed to create a network in GeNIe.
Do I understand correctly that you want to connect all nodes from one layer with all nodes of another layer including time steps?
Do I understand correctly that you want to connect all nodes from one layer with all nodes of another layer including time steps?
-
- Posts: 34
- Joined: Thu Mar 19, 2020 11:49 am
Re: I can not import pysmile in my mac.
yes. first I create all nodes according to my datasets in BBN, the second step is to put these variables in the temporal plate, the third step is to connect temporal arcs and normal arcs among these nodes. all these 3 steps were made in GeNIe, but the GeNIe will shut down when i create arcs in step 3.
so i try to create DBN in python according to tutorial 6. actually, this tutorial shown that i need to create all nodes first, like nodes1=self.create_cpt_node(net,"nodes1","nodes 1", 80,90) to add all nodes first. the second step is to set initial cpt like rain_def=[0.3,0.7,0.01,0.99]. i find it is difficult to create all cpt. because for me some nodes have more than 56000 cell. because the number of parents is 7, and the classification of them are 10,2,7,5,10,5,4,4, 10*2*7*5*10*4*4=560000, i have many nodes like this ,so i guess maybe thee are some simple methods to create my DBN, and I have not found this method. so I ask for help.
for me, i will create all nodes (with classification and initial probability) and put them in temporal plate first, the second step is to add normal arcs and temporal arcs in python. do i also need to set cpts of these nodes (like rain_def_temporal=[0.7,0.3,0.01,0.99]) in python if i create nodes in genie in step 1?
anyway, i ask help from you for a simple way to create DBN like i make simple DBN network in Genie. the 560000 cells cpt is too difficult to edit them.
so i try to create DBN in python according to tutorial 6. actually, this tutorial shown that i need to create all nodes first, like nodes1=self.create_cpt_node(net,"nodes1","nodes 1", 80,90) to add all nodes first. the second step is to set initial cpt like rain_def=[0.3,0.7,0.01,0.99]. i find it is difficult to create all cpt. because for me some nodes have more than 56000 cell. because the number of parents is 7, and the classification of them are 10,2,7,5,10,5,4,4, 10*2*7*5*10*4*4=560000, i have many nodes like this ,so i guess maybe thee are some simple methods to create my DBN, and I have not found this method. so I ask for help.
for me, i will create all nodes (with classification and initial probability) and put them in temporal plate first, the second step is to add normal arcs and temporal arcs in python. do i also need to set cpts of these nodes (like rain_def_temporal=[0.7,0.3,0.01,0.99]) in python if i create nodes in genie in step 1?
anyway, i ask help from you for a simple way to create DBN like i make simple DBN network in Genie. the 560000 cells cpt is too difficult to edit them.
-
- Site Admin
- Posts: 1417
- Joined: Mon Nov 26, 2007 5:51 pm
Re: I can not import pysmile in my mac.
Note that you can use parameter learning (EM algorithm) with the DBN. Create the structure first (including the temporal arcs), then run the parameter learning and your CPTs will be set based on the data.
-
- Posts: 34
- Joined: Thu Mar 19, 2020 11:49 am
Re: I can not import pysmile in my mac.
thanks for your answer. at first i can not add all temporal arcs in GeNIe because it will shut down when i store them or make parameters learning. fortunately, I add these arcs one by one and store them after each add arcs action, I got my DBN network.
but there are still parameter learning problems. I can get the cpts when i use a simple network according to my datesets, however, when i use my complex DBN nework, it showns errors, i just changed the name of file.xdsl. I explain my procedure and problems in the document. and i list my other questions in the document too. Could you please help me to solve my problems? I have tried many mehtods to create my DBN and make inference for my items these days,actually i really need to ask help from you even though i read the smile wrappers for many times.
the questions in the document mainly are:
Q1: I use the same dataset to create two DBN network, the picture 1 is the simple DBN network, and I can see the all Temporal beliefs for nodes from time 0 to time 3. However, when I change the complex DBN file.xdsl like picture 2, I only change the net.read_file(‘name’), I can not get the beliefs of nodes, and get some errors. You can see the error(red words) in picture 3. The error said: EM: can’t set evidence in record 1 for node Birth, etc. Could you please tell me how can I solve this problems?
Q2: I use the simple file.xdsl and same datasets to make the validator according to the SMILE manual, I have not add anything but the code provided by manual, as shown in picture 4, but I also get the error, as shown in picture 5. could you please tell me what should I add or change my code?
Q3: to solve my Q1, I try to set target nodes, like net.is_targe("Age"), self.update_and_show_temporal_results(net), but I also get the beliefs of all nodes twice, why my target nodes seems useless? Actually, I want to set “Event 1”,”Event 2” and much more nodes like “Event n” as target nodes to decrease the calculation time. Does the code is net.is_temporal_target(“Age”) or net.is_target(“Age”) if I want to set target nodes like I set them in temporal plate area in GeNIe?
Q4: I want to use the probability of nodes like “EVENT1”, “Event 2”,etc to simulate what kind of state they will use, like for item 1, the probability of Event 1 is (0.75,0.01,0.2,0.04) for state 1 to state 4. I want to add a simulate procedure by this probability, then add a new column to store the simulated state of Event1. Could you please tell how can I extract this probability of nodes after self.update_and_show_temporal_results(net)?
Thanks for your time and patience!
but there are still parameter learning problems. I can get the cpts when i use a simple network according to my datesets, however, when i use my complex DBN nework, it showns errors, i just changed the name of file.xdsl. I explain my procedure and problems in the document. and i list my other questions in the document too. Could you please help me to solve my problems? I have tried many mehtods to create my DBN and make inference for my items these days,actually i really need to ask help from you even though i read the smile wrappers for many times.
the questions in the document mainly are:
Q1: I use the same dataset to create two DBN network, the picture 1 is the simple DBN network, and I can see the all Temporal beliefs for nodes from time 0 to time 3. However, when I change the complex DBN file.xdsl like picture 2, I only change the net.read_file(‘name’), I can not get the beliefs of nodes, and get some errors. You can see the error(red words) in picture 3. The error said: EM: can’t set evidence in record 1 for node Birth, etc. Could you please tell me how can I solve this problems?
Q2: I use the simple file.xdsl and same datasets to make the validator according to the SMILE manual, I have not add anything but the code provided by manual, as shown in picture 4, but I also get the error, as shown in picture 5. could you please tell me what should I add or change my code?
Q3: to solve my Q1, I try to set target nodes, like net.is_targe("Age"), self.update_and_show_temporal_results(net), but I also get the beliefs of all nodes twice, why my target nodes seems useless? Actually, I want to set “Event 1”,”Event 2” and much more nodes like “Event n” as target nodes to decrease the calculation time. Does the code is net.is_temporal_target(“Age”) or net.is_target(“Age”) if I want to set target nodes like I set them in temporal plate area in GeNIe?
Q4: I want to use the probability of nodes like “EVENT1”, “Event 2”,etc to simulate what kind of state they will use, like for item 1, the probability of Event 1 is (0.75,0.01,0.2,0.04) for state 1 to state 4. I want to add a simulate procedure by this probability, then add a new column to store the simulated state of Event1. Could you please tell how can I extract this probability of nodes after self.update_and_show_temporal_results(net)?
Thanks for your time and patience!
- Attachments
-
- Questions (wecompress.com) (1).docx
- (274.56 KiB) Downloaded 325 times
-
- Site Admin
- Posts: 61
- Joined: Mon Nov 06, 2017 6:41 pm
Re: I can not import pysmile in my mac.
Ad 1:
There could be mismatch between DataSet and Network. If your network contains deterministic nodes and dataset contains informations conflicting with network EM Algorithm will not work.
You can attach DataSet and XDSL to next message - this will allow us to check what is wrong.
Ad 2:
There is an inaccuracy in constructor call - you should call
not
Ad 3:
Method is_target only checks that the node is target. If you want to set target, you have to call e.g.
If you want to clear target, you can use
or
Ad 4:
You can get node value by calling function:
Node definition could be accessed by:
Node temporal definition:
There could be mismatch between DataSet and Network. If your network contains deterministic nodes and dataset contains informations conflicting with network EM Algorithm will not work.
You can attach DataSet and XDSL to next message - this will allow us to check what is wrong.
Ad 2:
There is an inaccuracy in constructor call - you should call
Code: Select all
pysmile.learning.Validator(net, ds, matching)
Code: Select all
pysmile.learning.Validator(ds, net, matching)
Method is_target only checks that the node is target. If you want to set target, you have to call e.g.
Code: Select all
net.set_target("node_ID", True)
Code: Select all
net.set_target("node_ID", False)
Code: Select all
net.clear_all_targets()
You can get node value by calling function:
Code: Select all
net.get_node_value("node_ID")
Code: Select all
net.get_node_definition("node_ID")
Code: Select all
net.get_node_temporal_definition("node_ID",slice)