mount wl bl list

# Clean environment

closeAllConnections()

rm(list=ls())

# Set enviroment

setwd("~/your working directory")

# Load packages

library(bnpa)

library(bnlearn)

# Load data sets from package

data.to.work<-dataQuantC

head(data.to.work)

###################################################################################

# mount.wl.bl.list.R - Mounts a white or black list.

###################################################################################

# Mounting the black list

vlist <- ("A-C,D-F")

bl <- mount.wl.bl.list(vlist)

# Mounting the white list

vlist <- ("A-B,D-G")

wl <- mount.wl.bl.list(vlist)

# Learn the BN structure without black and white list

bn.structure <- hc(data.to.work, whitelist = wl, blacklist = bl)

# Set the name of a text to save the bn parameters

param.name <- "docbnparamHC.txt"

# Generates a BN parameters from the BN structure and write a text file with this

bn.param <- gera.bn.param(bn.structure, data.to.work, param.name)

# Set the graph name

graph.name <- "imgBNHC"

# Save the graph

mount.graph(bn.structure, bn.param, graph.name, data.to.work)

###################################################################################

RESULTS:

###################################################################################

The BN without black and white list:

The BN with black and white list, observe the changings:

  • not allowed: A to C and D to F

  • mandatory : A to B and D to G