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
5
votes
1 answer

BNlearn R error “variable Variable1 must have at least two levels.”

Trying to create a BN using BNlearn, but I keep getting an error; Error in check.data(data, allowed.types = discrete.data.types) : variable Variable1 must have at least two levels. It gives me that error for every of my variable, even though…
rhl94
  • 49
  • 3
5
votes
1 answer

bnlearn + Rgraphviz: double arrows instead of undirected edges when customizing plots

I am trying to customize a plot of a graph learned with bnlearn using RGraphviz. When I have undirected edges, RGraphviz turns them into directed edges to both directions when I try to customize the appearance of the graph. A reproducible example…
jcp
  • 749
  • 6
  • 21
5
votes
2 answers

Data type error with bn.fit() in R: variable is not supported in bnlearn (type: integer)

Based on a given network structure, I created a data frame of 100 instances for six binary variables(x1 to x6). So it's a 100 x 6 data frame of 0/1 values stored in a variable 'input_params'. Created an empty graph using statements: …
Vash
  • 1,767
  • 2
  • 12
  • 19
5
votes
1 answer

How to increase the size of the text in a Bayesian network plot with bnlearn in R

I am trying to draw a Bsyesian Network in R with bnlearn. Here is the my R code library(bnlearn) library(Rgraphviz) first_variable <- rnorm(100) second_variable <- rnorm(100) third_variable <- rnorm(100) v <-…
Günal
  • 751
  • 1
  • 14
  • 29
4
votes
1 answer

bnlearn::bn.fit difference and calculation of methods "mle" and "bayes"

I try to understand the differences between the two methods bayes and mle in the bn.fit function of the package bnlearn. I know about the debate between the frequentist and the bayesian approach on understanding probabilities. On a theoretical level…
locom
  • 115
  • 9
4
votes
1 answer

R bnlearn eval inside function

I am using the bnlearn package in R to train a Bayesian network. I have troubles with the following code (slightly modified bnlearn example code): library(bnlearn) data(learning.test) fitted = bn.fit(hc(learning.test),…
Jam
  • 43
  • 2
3
votes
1 answer

R masking conflict: packages bnlearn and sna

I have problems to parallely use R packages bnlearn and sna. The following example is straightforward: library(bnlearn) data("asia") # build network a <- hc(asia) # output a The output is as expected: Bayesian network learned via Score-based…
locom
  • 115
  • 9
3
votes
0 answers

Error in hill.climbing : INTEGER() can only be applied to a 'integer', not a 'NULL'

I'm trying to use hill-climbing function hc() in bnlearn package . Despite that all columns of my data frame are factor and carry no NA values, I still kept getting such error message: Error in hill.climbing(x = x, start = start, whitelist =…
3
votes
0 answers

bnlearn package: unexpected cpdist (prediction) behaviour

I encounter a problem that goes beyond my understanding. I have made a simple reproducible example for you to test it out. Basically I create a Bayesian network with two strongly correlated variables that are linked together. One would expect that…
Joel H
  • 173
  • 15
2
votes
1 answer

How do I graph a Bayesian Network with instantiated nodes using bnlearn and graphviz?

I am trying to graph a Bayesian Network (BN) with instantiated nodes using the libraries bnlearn and Rgraphviz. My workflow is as follow: After creating a data frame with random data (the data I am actually using is obviously not random) I then…
2
votes
1 answer

How to change probability table in object of class bn.fit (bn.fit.dnet) from bnlearn library?

I try to modify object of class bn.fit (bn.fit.dnet) from R's bnlearn library. I need to set equal probabilities for every row in bn.fit$node$prob table. For this I use next code: library(bnlearn) library(purrr) data(insurance) bn <-…
drastega
  • 1,581
  • 5
  • 30
  • 42
2
votes
0 answers

Bayesian Networks: Structure Learning in Python is extremely slow compared to R

I'm currently working on a problem to do image classification on images using Bayesian Networks. I have tried using pomegranate, pgmpy and bnlearn. My dataset contains more than 200,000 images, on which I perform some feature extraction algorithm…
Hari Krishnan
  • 2,049
  • 2
  • 18
  • 29
2
votes
2 answers

Setting layers for a Dynamic Bayesian Network with bnstruct in R

I am currently creating a DBN using bnstruct package in R. I have 9 variables in each 6 time steps. I have biotic and abiotic variables. I want to prevent the biotic variables to be parents of the abiotic variables.For a Bayesian Network, it's…
FrsLry
  • 348
  • 4
  • 19
2
votes
1 answer

Importing any function from an R package into python

While using the rpy2 library of Python to work with R. I get the following error message while trying to import a function of the bnlearn package: # Using R inside python import rpy2 import rpy2.robjects as robjects import rpy2.robjects.packages as…
Miguel Trejo
  • 5,913
  • 5
  • 24
  • 49
2
votes
0 answers

Reproducibility of output from gs (bnlearn) from "Bayesian Networks in R" book

In the book "Bayesian Networks in R", the authors learn the structure of the marks data set using the Grow - Shrink implementation. Should I expect the gs function to give different outputs for the learned structure? Perhaps maybe just learn a…
astudent
  • 37
  • 1
  • 7
1
2 3 4 5 6