Questions tagged [bnlearn]

bnlearn is an R package for learning the graphical structure of Bayesian networks, estimate their parameters and perform some useful inference.

bnlearn is an R package for learning the graphical structure of Bayesian networks, estimate their parameters and perform some useful inference. To get started and install the latest development snapshot type

install.packages(​"http://www.bnlearn.com/releases/​bnlearn_latest.tar.gz") in your R console.

Package webpage: http://www.bnlearn.com/

89 questions
2
votes
1 answer

BNLearn: How to merge the estimating parameters of a Gaussian Bayesian network with its conditional structure?

I defined the structure of a Gaussian Bayesian network using the iamb function and then estimated the coefficients of the nodes using bn.fit. Library library(bnlearn) Data { C E G N V W 48.83 51.48 42.64 54.1 …
Pbcacao
  • 35
  • 4
2
votes
0 answers

cpquery function of bnlearn always returns 0 for simple discrete artificial data

I want to calculate conditional probabilities based on a bayesian network based on some binary data I create. However, using the bnlearn::cpquery, always a value of 0 is returned, while bnlearn::bn.fit fits a correct model. # Create data for binary…
Ivar K
  • 21
  • 2
2
votes
1 answer

Can the parallel or snow packages in R interface with a spark cluster?

I am dealing with a computationally intensive package in R. This package has no alternative implementations that interfaces with a Spark cluster;however, it does have an optional argument to take in a cluster created with the parallel package. My…
niccalis
  • 134
  • 1
  • 7
2
votes
1 answer

How bnlearn calculates BIC of continuous data?

I'm using bnlearn package in R, and I would like to know how the package calculates BIC-g (the BIC in Gaussian distribution). Let's make a structure, and I can find BIC score as follows library(bnlearn) X = iris[, 1:3] names(X) = c("A", "B",…
moreblue
  • 322
  • 1
  • 4
  • 16
2
votes
0 answers

Bayesian networks for text analysis in R

I have one page story (i.e. text data), I need to use Bayesian network on that story and analyse the same. Could someone tell me whether it is possible in R? If yes, that how to proceed? The objective of the analysis is - Extract Action Descriptions…
Praveen Chougale
  • 373
  • 3
  • 11
2
votes
1 answer

bnlearn setting and dropping arcs inplace

Looking at http://www.bnlearn.com/documentation/man/arcops.html, the way to drop arcs is to use the drop.arcs function. It doesn't seem to be dropping it though library(bnlearn) data(learning.test) res = gs(learning.test) arcs(res) from to…
Jean
  • 1,480
  • 15
  • 27
2
votes
2 answers

Splitting a graphical network string in R

I have the following string derived from a Bayesian Network learning algorithm (like from bnlearn or deal packages): [1] "[wst|af:bq:rloss_s:pre3][af|bq][d|wst:af:con:rloss_s][bq|con][con|af][rloss_s|af:con:pre3][pre3|af:con]" The string defines…
viktor_r
  • 701
  • 1
  • 10
  • 21
2
votes
1 answer

Prediction with cpdist using "probabilities" as evidence

I have a very quick question with an easy reproducible example that is related to my work on prediction with bnlearn library(bnlearn) Learning.set4=cbind(c("Yes","Yes","Yes","No","No","No"),c(9,10,8,3,2,1)) …
Joel H
  • 173
  • 15
1
vote
1 answer

Why TABU algorithm in bnlearn gives error for some numeric type dataset?

I was trying to use 'tabu' algorithm in bnlearn package in r to draw the Bayesian network. I have a data frame contains large data set and all of the columns are numeric type. I am getting the following error: Error in if (abs(x1 - x2) <…
AKC
  • 21
  • 1
1
vote
1 answer

Why the predicted values in BNLEARN changes each time I run the code?

I am using BNLEARN package in R to predict a variable. I noticed each time I run the code, the predicted values keep updating. Can you explain why this happens? my code is below: res=hc(training, start = NULL, whitelist = NULL, blacklist = NULL,…
AKC
  • 21
  • 1
1
vote
0 answers

Get reproducible results (bayesian network) using boot.strength from bnlearn package

I have 2 questions on bayesian network with bnlearn package in R. library(parallel) cl = makeCluster(4) set.seed(1) b1 = boot.strength(data = learning.test, R = 5, algorithm = "hc", cluster = cl, algorithm.args = list( score="bde", iss = 60 ,…
Kumar
  • 43
  • 7
1
vote
1 answer

Understanding the event and evidence parameters in bnlearns cpquery

I followed the example for cpquery(fitted, event, evidence, cluster, method = "ls", ..., debug = FALSE) given in the documentation: #rm(list=ls()) library(bnlearn) data(learning.test) fitted = bn.fit(hc(learning.test), learning.test) # the result…
McGonald
  • 13
  • 2
1
vote
1 answer

Does bnlearn compute for non-linear correlations?

I've recently started using the bnlearn package in R for detecting Markov Blankets of a target node in the dataset. Based on my understanding of Bayesian Inference, two nodes are connected if there is a causal relationship between the two and this…
mangoland
  • 13
  • 3
1
vote
1 answer

R Bayesian Network average model (Max-Min HC): Error in bn.fit, the graph is only partially directed

Goodmorning everyone, This is Riccardo from Italy. This is my first rodeo on StackOverflow's question, so sorry if I'am doing something wrong. I am also not so expert about coding in R and I am struggling with the following issue: I am try to build…
1
vote
1 answer

bnlearn Error: Wrong number of conditional probability distributions

I am learning to work with bnlearn and I keep running into the following error in the last line of my code below: Error in custom.fit(dag, cpt) : wrong number of conditional probability distributions What am I doing wrong? modelstring(dag)=…