Code Examples for parameter learning/data generation in R

The engine.
Post Reply
rreichenberg
Posts: 6
Joined: Tue Sep 12, 2017 4:35 pm

Code Examples for parameter learning/data generation in R

Post by rreichenberg »

First, thank you for all of the information that is available on your site (including the Wiki). I am looking for software that is compatible with dynamic Bayesian networks containing latent variables (discrete) and that can perform both parameter learning as well as inference. Ideally, this software would integrate easily with R. I'm hoping SMILE/jSMILE will do the trick. There is a surprising lack of any such packages in R that handle networks with latent variables (at least for networks more complex than a HMM). To that end, do you have any examples of code for conducting the parameter learning (via EM, for example) in R using rJava? Also, is there a function for generating data (i.e., sampling cases from a target network)? I see the examples for defining a network and conducting inference in the Wiki but nothing for learning/data generation. Thank you in advance.
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Code Examples for parameter learning/data generation in R

Post by shooltz[BayesFusion] »

Do you have any examples of code for conducting the parameter learning (via EM, for example) in R using rJava?
We don't have any examples specific to R or rJava. If the plain Java example would be sufficient, have a look at jSMILE sources (available for download at our website). The zip file with the source code contains testApp.java, which test various parts of jSMILE functionality, including EM parameter learning.

Also, is there a function for generating data (i.e., sampling cases from a target network)? I see the examples for defining a network and conducting inference in the Wiki but nothing for learning/data generation.
This functionality is available in SMILE (C++) library. We didn't provide the Java interface so far - mostly because nobody has asked for it.
rreichenberg
Posts: 6
Joined: Tue Sep 12, 2017 4:35 pm

Re: Code Examples for parameter learning/data generation in R

Post by rreichenberg »

We don't have any examples specific to R or rJava. If the plain Java example would be sufficient, have a look at jSMILE sources..."
Thanks. I'll take a look. I don't have much experience with Java/C++ so I'm kind of trying to reverse engineer the R examples. If you come across any examples, I'd be interested in seeing them. They don't have to be "official." Community-provided examples would be sufficient.
This functionality is available in SMILE (C++) library.
Does that mean that those functions are not available to be called by R?
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Code Examples for parameter learning/data generation in R

Post by shooltz[BayesFusion] »

Does that mean that those functions are not available to be called by R?
You can call this functionality from R using R's C/C++ interface, at least in theory :)
rreichenberg
Posts: 6
Joined: Tue Sep 12, 2017 4:35 pm

Re: Code Examples for parameter learning/data generation in R

Post by rreichenberg »

Perhaps it would be easier for me to design/run my Monte Carlo simulation in C++. Is all of the functionality I need (data generation/parameter learning/inference for a dynamic Bayesian networks containing potentially multiple latent variables per time slice as well as the ability to be automated/looped) available native in the C++ library?
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Code Examples for parameter learning/data generation in R

Post by shooltz[BayesFusion] »

Is all of the functionality I need (data generation/parameter learning/inference for a dynamic Bayesian networks containing potentially multiple latent variables per time slice as well as the ability to be automated/looped) available native in the C++ library?
Yes, it's available. I encourage you to explore this functionality using GeNIe, which basically provides a GUI for SMILE. GeNIe is available for download at https://download.bayesfusion.com/. If you prefer to read GeNIe's manual first, go to http://support.bayesfusion.com/docs/.
rreichenberg
Posts: 6
Joined: Tue Sep 12, 2017 4:35 pm

Re: Code Examples for parameter learning/data generation in R

Post by rreichenberg »

I encourage you to explore this functionality using GeNIe
Using a GUI (GeNIe or Netica, which is what I currently use) would be preferable for a one-time analysis but I need to conduction 1,000 replications/analyses for each of 200-300 conditions using synthetic data. That's not feasible with a point-and-click interface unless there is some built-in automation functionality with GeNIe that I am not aware of.
rreichenberg
Posts: 6
Joined: Tue Sep 12, 2017 4:35 pm

Re: Code Examples for parameter learning/data generation in R

Post by rreichenberg »

Learning C++/Java would be the smart thing to do if I had the time. As it is, I'd really need to stay within R/Python/Matlab.
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Code Examples for parameter learning/data generation in R

Post by shooltz[BayesFusion] »

My point is that you can download GeNIe and use it to check if the functionality you need is there. If it is not, you don't need to worry about stuff missing from jSMILE.
rreichenberg
Posts: 6
Joined: Tue Sep 12, 2017 4:35 pm

Re: Code Examples for parameter learning/data generation in R

Post by rreichenberg »

Good idea. Generating data is easy enough with a simple R script (or using existing R packages such as bnlearn, deal, etc.) so I'm not worried about that. The only thing I really need is a reasonably easy way to learn the parameters of a dynamic Bayes net with latent variables from data in R. It sounds like I can do that with SMILE via jSMILE via rJava. I just need to find some example code to guide me along the way. The stuff on the wiki gets me through defining a network. I'll work on figuring out how to conduct parameter learning and get the results into an R object for post-processing. If anyone in the community has a code example, feel free to DM it to me.
Post Reply