Node Clustering in Probabilistic Graphical Models — Bayesian Networks Explainability

--

I recently published the new version of “bnviewer”, the package is in version 0.1.4 and contains a feature that allows us to group Bayesian Network nodes through custom icons to facilitate the interpretability and categorization of variables in complex models. of Bayesian Networks.

I would like to thank Researcher Matías Alberto Vergara Álvarez at the Pontificia Universidad Católica de Chile for the suggestion in the package. Matías has work with AI applied to genomics and has described the importance of differentiating between the different “roles” that genes play, and this functionality would bring many benefits in this type of research.

BNViewer — Interactive Visualization of Bayesian Networks

Bayesian networks provide an intuitive framework for probabilistic reasoning and its graphical nature can be interpreted quite clearly. Graph based methods of machine learning are becoming more popular because they offer a richer model of knowledge that can be understood by a human in a graphical format. The “bnviewer” is an R Package that allows the interactive visualization of Bayesian Networks. The aim of this package is to improve the Bayesian Networks visualization over the basic and static views offered by existing packages.

This package originated from my Master’s project in Mathematics, Statistics and Applied Computing to Industry at the Institute of Mathematical and Computer Sciences of the University of São Paulo — ICMC-USP, under the supervision of Prof. Dr. Alneu Andrade Lopes and co-supervision of Dr. Brett Drury.

Example — Node Clustering in Probabilistic Graphical Models — Bayesian Networks Explainability

You can install the stable version of bnviewer from CRAN:

install.packages("bnviewer")

Import the bnlearn and bnviewer packages

library(bnlearn)
library(bnviewer)

Import the desired dataset and apply a structure learning algorithm. Example (Hill-Climbing (HC)).

data("alarm")
bn.learn.hc = hc(alarm)

Call the viewer function of the “bnviewer” package with the desired parameters.

clusters.legend.title = "<b>Legend</b> <br> Variable Categories"

viewer(bn.learn.hc,
bayesianNetwork.background = "-webkit-radial-gradient(center,
ellipse cover,
rgba(255,255,255,1) 0%,
rgba(246,246,246,1) 47%,
rgba(237,237,237,1) 100%)",

bayesianNetwork.width = "100%",
bayesianNetwork.height = "100vh",
bayesianNetwork.layout = "layout_components",
bayesianNetwork.title="<br>Discrete Bayesian Network - Alarm",
bayesianNetwork.subtitle = "Monitoring of emergency care patients",

node.colors = list(background = "white",
border = "black",
highlight = list(background = "#e91eba",
border = "black")),

node.font = list(color = "black", face="Arial"),

clusters.legend.title = list(text = clusters.legend.title,
style = "font-size:18px;
font-family:Arial;
color:black;
text-align:center;"),

clusters.legend.options = list(

list(label = "Pressure",
shape = "icon",
icon = list(code = "f1ce", size = 50, color = "#e91e63")),
list(label = "Volume",
shape = "icon",
icon = list(code = "f140", size = 50, color = "#03a9f4")),
list(label = "Ventilation",
shape = "icon",
icon = list(code = "f192", size = 50, color = "#4caf50")),
list(label = "Saturation",
shape = "icon",
icon = list(code = "f10c", size = 50, color = "#ffc107"))
),

clusters = list(
list(label = "Pressure",
shape = "icon",
icon = list(code = "f1ce", color = "#e91e63"),
nodes = list("CVP","BP","HRBP","PAP","PRSS")),
list(label = "Volume",
shape = "icon",
icon = list(code = "f140", color = "#03a9f4"),
nodes = list("MINV","MVS","LVV","STKV")),
list(label = "Ventilation",
shape = "icon",
icon = list(code = "f192", color = "#4caf50"),
nodes = list("VALV","VLNG","VTUB","VMCH")),
list(label = "Saturation",
shape = "icon",
icon = list(code = "f10c", color = "#ffc107"),
nodes = list("HRSA","SAO2","PVS"))
)
)

Visualization

You can use the unicode code from the FontAwesome 4.7 icons to customize Bayesian Network nodes and define clusters.

To the next…

I hope this approach can contribute to those who are starting in the area of Data Science, whether Statistics, Mathematicians, Computer Scientists or students who have an interest in the subject.

--

--