Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@lp6m
Created November 7, 2019 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lp6m/54ac9a95182610c9643928578f11dcb6 to your computer and use it in GitHub Desktop.
Save lp6m/54ac9a95182610c9643928578f11dcb6 to your computer and use it in GitHub Desktop.
Generate bayesian network sample data from learned network structure on R
#sudo apt install r-base-core #the latest version will not be installed by this command
#install.packages("bnlearn", dependencies = TRUE)
library(bnlearn)
data(alarm)
res = read.bif("./alarm.bif") #http://www.bnlearn.com/bnrepository/discrete-medium.html#alarm
sim = rbn(res, 500, alarm)
write.csv(sim, "./alarm.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment