Bayesian Network - Dependency Direction

Hi There,

I am trying to build a Learning Bayesian Network model to understand Traffic density. Traffic density is to be explained by variables Hour of day, Day of week, Weather condition & Accidents (y/n).

The Bayesian network model is correctly identifying that there is a relationship between Traffic Levels and the explanatory variables but the dependence is incorrect (judging from the direction of the arrows). However, when looking at the CPTs the probabilities seem to make sense. Is there anyway that I could get the model to naturally figure out the dependence? (without black/white listing).

I am using R. The package is "bnlearn". The algorithm is either going to be Hill-Climbing or Naive Bayes (as they say this is good for prediction).

The BN is attached


#--------------------------R Code------------------

## data object called d2.



## 75% of the sample size

smp_size <- floor(0.778271 * nrow(d2))

## set the seed to make your partition reproductible


train_ind <- sample(seq_len(nrow(d2)), size = smp_size)

train <- d2[train_ind, ]

test <- d2[-train_ind, ]



b1 = tree.bayes(train,"Traffic_Level") # learn BN structure on training set


b2 = hc(train)

b1fitted =, train, method = "bayes")



After further digging, I found that Learning Bayesian networks, at times:

1. may not learn all the “expected” edges, and
2. may learn in the wrong direction

Hence, I eventually had to whitelist & blacklist (basically a function that allows you to either force onto or remove relationships between nodes within the bnlearn package in R). I was hoping for these relationships to emerge naturally.

Ofer Mendelevitch is an expert in this area, please watch the youtube video below for a quick intro of Bayesian networks in R and the real world...