Coder Social home page Coder Social logo

paulgovan / bayesiannetwork Goto Github PK

View Code? Open in Web Editor NEW
115.0 115.0 39.0 70.26 MB

Bayesian Network Modeling and Analysis

Home Page: http://paulgovan.github.io/BayesianNetwork/

License: Apache License 2.0

R 4.44% TeX 0.25% HTML 95.31%
bayesian-networks learning-algorithm network-measures r

bayesiannetwork's People

Contributors

paulgovan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bayesiannetwork's Issues

The csv format

I want to know the exact format of the uploaded csv file to build network, can you offer us some examples?

Inference ShinyApp

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).

  1. 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 ""

  2. 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]

  3. 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)

paper.md attributions

openjournals/joss-reviews#425

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!

Release BayesianNetwork 0.3.2

Prepare for release:

  • git pull
  • Check current CRAN check results
  • Polish NEWS
  • 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)
  • Update cran-comments.md
  • git push

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted ๐ŸŽ‰
  • usethis::use_github_release()
  • usethis::use_dev_version(push = TRUE)

Inference on multiple evidence nodes?

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.

Request Help

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

bnlearn d3 package

A simple package for building interactive networks with d3 from bnlearn Bayesian networks.

Unit tests

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.

Adjust height of plots

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.

Release BayesianNetwork 0.2.0

Prepare for release:

  • git pull
  • Check current CRAN check results
  • Check if any deprecation processes should be advanced, as described in Gradual deprecation
  • Polish NEWS
  • 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)
  • Update cran-comments.md
  • git push
  • Draft blog post

Submit to CRAN:

  • usethis::use_version('minor')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted ๐ŸŽ‰
  • git push
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • git push
  • Finish blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

paper missing references

"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).

Bayesian Network Predictor

How does R shiny know what its predicting in an R Shiny bayesian network app? Is this defined in the code somewhere?

Gaussian Bayesian Network

Hello,

Is that possible to compute Gaussian Bayesian Network using "Bayesian network" tool ?

Thaks a lot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.