Constraint-based structure learning algorithms:
Score-based structure learning algorithms:
Hybrid structure learning algorithms:
Local discovery algorithms:
install.packages("bnviewer")
bnviewer is available for developers, install from GitHub.
install.packages("devtools")
devtools::install_github("robson-fernandes/bnviewer")
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.
viewer(bn.learn.hc,
bayesianNetwork.width = "100%",
bayesianNetwork.height = "80vh",
bayesianNetwork.layout = "layout_with_sugiyama",
bayesianNetwork.title="Discrete Bayesian Network - Alarm",
bayesianNetwork.subtitle = "Monitoring of emergency care patients",
bayesianNetwork.footer = "Fig. 1 - Layout with Sugiyama"
)
Example of Bayesian network visualization with custom nodes and grid layout.
viewer(bn.learn.hc,
bayesianNetwork.width = "100%",
bayesianNetwork.height = "80vh",
bayesianNetwork.layout = "layout_on_grid",
bayesianNetwork.title="Discrete Bayesian Network - Alarm",
bayesianNetwork.subtitle = "Monitoring of emergency care patients",
bayesianNetwork.footer = "Fig. 2 - Layout on grid",
node.colors = list(background = "#f4bafd",
border = "#2b7ce9",
highlight = list(background = "#97c2fc",
border = "#2b7ce9"))
)
Example of Bayesian network visualization with strength viewer function.
bayesianNetwork.boot.strength = boot.strength(alarm, R = 20, algorithm = "hc")
avg.bayesianNetwork = averaged.network(bayesianNetwork.boot.strength, threshold = 0.2)
strength.viewer(
avg.bayesianNetwork,
bayesianNetwork.boot.strength,
bayesianNetwork.background = "#282c34",
bayesianNetwork.arc.strength.threshold.expression = c("@threshold > 0 & @threshold < 0.5",
"@threshold >= 0.5 & @threshold <= 0.8",
"@threshold > 0.8 & @threshold <= 1"),
bayesianNetwork.arc.strength.threshold.expression.color = c("red", "yellow", "blue"),
bayesianNetwork.arc.strength.threshold.alternative.color = "white",
bayesianNetwork.arc.strength.label = TRUE,
bayesianNetwork.arc.strength.label.prefix = "",
bayesianNetwork.arc.strength.label.color = "white",
bayesianNetwork.arc.strength.tooltip = TRUE,
bayesianNetwork.edge.scale.min = 1,
bayesianNetwork.edge.scale.max = 3,
bayesianNetwork.edge.scale.label.min = 14,
bayesianNetwork.edge.scale.label.max = 14,
bayesianNetwork.width = "100%",
bayesianNetwork.height = "800px",
bayesianNetwork.layout = "layout_with_sugiyama",
node.colors = list(background = "black",
border = "#2b7ce9",
highlight = list(background = "#e91eba",
border = "#2b7ce9")),
node.font = list(color = "white", face="Arial"),
edges.dashes = FALSE
)
viewer(bayesianNetwork, bayesianNetwork.title = "",
bayesianNetwork.subtitle = "", bayesianNetwork.footer = "",
bayesianNetwork.layout = "default", bayesianNetwork.width = "100%",
bayesianNetwork.height = "500px", node.shape = c("dot"),
node.label.prefix = "", node.colors = list(), edges.smooth = TRUE,
edges.dashes = FALSE, options.highlightNearest = TRUE,
options.nodesIdSelection = FALSE)
Arguments
|
A Bayesian Network structure. (Example : hill-climbing (HC)). |
|
: String. Bayesian Network title |
|
: String. Bayesian Network subtitle |
|
: String. Bayesian Network footer |
|
: String. A layout of a Bayesian Network
|
|
: String. Bayesian Network width |
|
: String. Bayesian Network height |
|
: String. A node shape of a Bayesian Network
|
|
: String. Adds a prefix to the node label |
|
: String | named list. Color for the node. Can be 'rgba(120,32,14,1)', '#97C2FC' (hexa notation on 7 char without transparency) or 'red'. Can be just one color, or a list with several elements:
|
|
: Boolean. When true, the edge is drawn as a dynamic quadratic bezier curve. |
|
: Array or Boolean. Default to false. When true, the edge will be drawn as a dashed line. |
|
: Boolean. Default to true. Highlight nearest when clicking a node. |
|
: Boolean. Default to false. Add an id node selection creating an HTML select element. |
strength.viewer(bayesianNetwork, bayesianNetwork.background = NULL,
bayesianNetwork.boot.strength = NULL,
bayesianNetwork.arc.strength.threshold.expression = NULL,
bayesianNetwork.arc.strength.threshold.expression.color = NULL,
bayesianNetwork.arc.strength.threshold.alternative.color = NULL,
bayesianNetwork.arc.strength.label = FALSE,
bayesianNetwork.arc.strength.label.prefix = "",
bayesianNetwork.arc.strength.label.color = NULL,
bayesianNetwork.arc.strength.tooltip = FALSE,
bayesianNetwork.edge.scale.min = 1,
bayesianNetwork.edge.scale.max = 5,
bayesianNetwork.edge.scale.label.min = 14,
bayesianNetwork.edge.scale.label.max = 14,
bayesianNetwork.title = "", bayesianNetwork.subtitle = "",
bayesianNetwork.footer = "", bayesianNetwork.layout = "default",
bayesianNetwork.width = "100%", bayesianNetwork.height = "500px",
node.shape = c("dot"), node.label.prefix = "",
node.colors = list(), node.font = list(), edges.smooth = TRUE,
edges.dashes = FALSE, edges.colors = list(),
options.highlightNearest = TRUE, options.nodesIdSelection = FALSE)
Arguments
|
A Bayesian Network structure from Averaged Network |
|
Bayesian network background |
|
A nonparametric bootstrap to assess arc strength and direction |
|
Logical expression of the force threshold of the arcs of the Bayesian network |
|
Color applied to logical expression of the force threshold of the arcs of the Bayesian network |
|
Alternative color to logical expression of the force threshold of the arcs of the Bayesian network |
|
Enable Bayesian Network arc strength label |
|
Include Bayesian Network arc strength label prefix |
|
Set Bayesian Network arc strength label color |
|
Enable Bayesian Network arc strength tooltip |
|
Set bayesian Network edge scale minimum |
|
Set bayesian Network edge scale maximum |
|
Set bayesian Network edge scale label minimum |
|
Set bayesian Network edge scale label maximum |
|
: String. Bayesian Network title |
|
: String. Bayesian Network subtitle |
|
: String. Bayesian Network footer |
|
: String. A layout of a Bayesian Network
|
|
: String. Bayesian Network width |
|
: String. Bayesian Network height |
|
: String. A node shape of a Bayesian Network
|
|
: String. Adds a prefix to the node label |
|
: String | named list. Color for the node. Can be 'rgba(120,32,14,1)', '#97C2FC' (hexa notation on 7 char without transparency) or 'red'. Can be just one color, or a list with several elements:
|
|
Node Font : Array. Example list(color = "black", face="Arial") |
|
: Boolean. When true, the edge is drawn as a dynamic quadratic bezier curve. |
|
: Array or Boolean. Default to false. When true, the edge will be drawn as a dashed line. |
|
: Named list or String. Default to named list. Color information of the edge in every situation. Can be 'rgba(120,32,14,1)', '#97C2FC' (hexa notation on 7 char without transparency) or 'red'.
|
|
: Boolean. Default to true. Highlight nearest when clicking a node. |
|
: Boolean. Default to false. Add an id node selection creating an HTML select element. |