paulgovan / bayesiannetwork Goto Github PK
View Code? Open in Web Editor NEWBayesian Network Modeling and Analysis
Home Page: http://paulgovan.github.io/BayesianNetwork/
License: Apache License 2.0
Bayesian Network Modeling and Analysis
Home Page: http://paulgovan.github.io/BayesianNetwork/
License: Apache License 2.0
I want to know the exact format of the uploaded csv file to build network, can you offer us some examples?
Could you please update the files on github since the hosted app is way different from the latest version available here
Hi! I absolutely LOVE the Shiny App you've made! It's incredibly inspiring and I want to fully understand it before applying something similar to my own data. This is my first go at a shiny app so I'm sorry if my questions are extremely obvious but it's hard to google some of these issues!
Specifically, I want to use a network I've already made and create what you have under the inference tab using that network.
I'm using the Alarm dataset in my example below, and rather than letting the event be specified I only want it to be "ACO2" (as seen in nodeProbs
).
I can't seem to get the buttons to generate the alarm col names dynamically so I defined the choices as colnames(dat)
in the Inputselect for input$evidenceNode
where you have it as ""
Similarly, I can't generate the input$evidence
drop down [I put choices = c("HIGH", "LOW", "NORMAL") but this isn't always the case so I'd like this to update dynamically]
When trying to debug I put specific arguments into nodeProbs but a graph still wont generate.
Again, I realize I'm asking a lot and I'm sorry in advanced if these questions are silly. Thank you for any help you can provide because the application you made is magnificent and I'm learning so much going through your code!
library(bnlearn)
library(shiny)
library(r2d3)
library(shinydashboard)
ui <- fluidPage(
box(
title = "Evidence",
status = "success",
width = NULL,
helpText("Select evidence to add to the model:"),
shiny::fluidRow(
shiny::column(6,
# Evidence node input select
shiny::selectInput(
"evidenceNode", label = shiny::h5("Evidence Node:"),
colnames(dat)
)),
shiny::column(6,
# Evidence input select
shiny::selectInput(
"evidence", label = shiny::h5("Evidence:"),
c("HIGH", "LOW", "NORMAL")
)
)
),
shiny::column(
width = 8,
# Event parameter box
shinydashboard::box(
title = "Event Parameter",
status = "success",
width = NULL,
# Event conditional PD plot
shiny::plotOutput("distPlot")
)
)
))
shinyServer(function(input, output, session) {
output$text <- renderText({
paste(input$evidenceNode)
})
data(alarm)
# input the alarm data
dat <- alarm
# structure of the network
modelstring = paste0("[HIST|LVF][CVP|LVV][PCWP|LVV][HYP][LVV|HYP:LVF][LVF]",
"[STKV|HYP:LVF][ERLO][HRBP|ERLO:HR][HREK|ERCA:HR][ERCA][HRSA|ERCA:HR][ANES]",
"[APL][TPR|APL][ECO2|ACO2:VLNG][KINK][MINV|INT:VLNG][FIO2][PVS|FIO2:VALV]",
"[SAO2|PVS:SHNT][PAP|PMB][PMB][SHNT|INT:PMB][INT][PRSS|INT:KINK:VTUB][DISC]",
"[MVS][VMCH|MVS][VTUB|DISC:VMCH][VLNG|INT:KINK:VTUB][VALV|INT:VLNG]",
"[ACO2|VALV][CCHL|ACO2:ANES:SAO2:TPR][HR|CCHL][CO|HR:STKV][BP|CO:TPR]")
dag = model2network(modelstring)
fit <- bnlearn::bn.fit(dag, dat, method = "bayes", iss = 5)
# Send the evidence node choices to the user
# shiny::observe({
# shiny::updateSelectInput(session, "evidenceNode", choices = names(dat()))
# })
# Send the evidence choices to the user
shiny::observe({
whichNode <- which(colnames(dat()) == input$evidenceNode)
evidenceLevels <- as.vector(unique(dat()[,whichNode]))
shiny::updateSelectInput(session, "evidence", choices = evidenceLevels)
})
# Perform Bayesian inference based on evidence and plot results
output$distPlot <- shiny::renderPlot({
if (is.null(dat()))
return(NULL)
if (all(sapply(dat, is.numeric)))
shiny::validate(
shiny::need(
try(distPlot != ""),
"Inference is currently not supported for continuous variables..."
)
)
# Create a string of the selected evidence
str1 <- paste0("(", input$evidenceNode, "=='", input$evidence, "')")
# Estimate the conditional PD and tabularize the results
nodeProbs <- prop.table(table(bnlearn::cpdist(fit(), "ACO2", eval(parse(text = str1)))))
# Create a bar plot of the conditional PD
barplot(
nodeProbs,
col = "lightblue",
main = "Conditional Probabilities",
border = NA,
xlab = "Levels",
ylab = "Probabilities",
ylim = c(0, 1)
)
})
})
shinyApp(ui = ui, server = server)
I would also love to have the ability to add expert knowledge to the model as described here,
http://www.bnlearn.com/examples/custom/
Though I have not been able to figure out how to update the bnlearn object from the ui as needed.
The review has the following checkbox, which is not fulfilled by the current paper.md: "Authors: Does the paper.md file include a list of authors with their affiliations?" Somewhat relatedly, in my opinion, it might be made clearer in the paper that you're providing a shiny
frontend to bnlearn
rather than implementing the learning algorithms yourself. Although you do very prominently say it's "powered" by bnlearn
, I feel it is best to be as clear as possible with author attribution!
Prepare for release:
git pull
usethis::use_github_links()
urlchecker::url_check()
devtools::build_readme()
devtools::check(remote = TRUE, manual = TRUE)
devtools::check_win_devel()
revdepcheck::revdep_check(num_workers = 4)
cran-comments.md
git push
Submit to CRAN:
usethis::use_version('patch')
devtools::submit_cran()
Wait for CRAN...
usethis::use_github_release()
usethis::use_dev_version(push = TRUE)
Thanks for the great app. Is it possible to do inference on nodes of interest after setting multiple evidence conditions. Is that something that you plan to add? Perhaps a list of evidence nodes in the source code? Would be very helpful if you can provide a code snippet that can be extended. Thanks.
Hi Paul,
Good day to you!
Your contribution on bayesian networks is very fascinating.
I am a student of Data Science and I am new to R programming.
I am trying to learn bayesian networks from data, but I am stuck at one point as I need my network to be built from selective variables of my dataset. For example, I am working on a test dataset which has 10 variables, but in this I need to use only 5 variables for my network.
Could you please help me with this.
Kind Regards,
Paras
A simple package for building interactive networks with d3 from bnlearn Bayesian networks.
This issue is for openjournals/joss-reviews#425
There doesn't seem to be an automated way to test whether the shiny app is working as expected. It seems to me that it would be good to have some tests to check, for example, for breaking changes to the shiny or bnlearn API.
I appreciate that it's not always easy to test web interfaces, and I'm not sure what would be best -- I haven't developed in shiny myself! But I did find RSelenium, which says that solutions are out there.
Is it possible to adjust the height of the plot views to the right according to the content: if my variables have more than five possible values (20...30 in my case) it gets unreadable. I think an option to double the height or in some cases have 4 times the original height could solve this issue. Alternatively sizing the font according to the available row height could mitigate the issue a bit, but you can't make the font size too small, so increasing the plot box height is preferable.
Spelled "Paramater"
I would love to be able to implement Bayesian Inference in this app as described here http://www.bnlearn.com/documentation/man/cpquery.html
See my first (poor) attempt in server.r lines 289-304 and ui.r lines 177-213
Prepare for release:
git pull
devtools::build_readme()
urlchecker::url_check()
devtools::check(remote = TRUE, manual = TRUE)
devtools::check_win_devel()
rhub::check_for_cran()
revdepcheck::revdep_check(num_workers = 4)
cran-comments.md
git push
Submit to CRAN:
usethis::use_version('minor')
devtools::submit_cran()
Wait for CRAN...
git push
usethis::use_github_release()
usethis::use_dev_version()
git push
"References: Do all archival references that should have a DOI list one (e.g., papers, datasets, software)?"
The paper as-is (in md and pdf form) is entirely missing a references section (even though I see you have populated the bib file).
How does R shiny know what its predicting in an R Shiny bayesian network app? Is this defined in the code somewhere?
Hello,
Is that possible to compute Gaussian Bayesian Network using "Bayesian network" tool ?
Thaks a lot
@paulgovan Which license is correct?
Apache here (and CRAN):
Line 12 in ba31a3b
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.