Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inference on multiple evidence nodes? #4

Open
Tavpritesh opened this issue Aug 2, 2017 · 7 comments
Open

Inference on multiple evidence nodes? #4

Tavpritesh opened this issue Aug 2, 2017 · 7 comments

Comments

@Tavpritesh
Copy link

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.

@paulgovan
Copy link
Owner

@Tavpritesh currently not possible but something I'd hoped to have time to work on. I suppose you could do this in the editor without leaving the app. I could get you a code snippet if needed. Otherwise I hope to have this option in the nearish future.

@Tavpritesh
Copy link
Author

Thanks Paul, a snippet would be very useful. Ability to do so will make BayesianNetwork "the tool" for my work. Currently we are tied down to a commercial software.

@paulgovan
Copy link
Owner

For example, using the default discrete network and entering the following in the editor:

prop.table(
    table(
        bnlearn::cpdist(fit(), "A", (C == "c") & (E == "c"))
    )
)

Gives you the conditional probability table for "A" given C = "c" and E = "c".

Glad to hear that you're enjoying the app. I would love to hear about the types of applications that you're using it for. I'm always looking for feedback too.

@Tavpritesh
Copy link
Author

@paulgovan Thanks for the snippet, much appreciated. I am using BayesianNetwork for healthcare related analysis and am hoping to extend it to a stand-alone app that we can build along with our paper. Since inference arrived, your package is my hope to avoid re-inventing the wheel while moving away from commercial software. I will keep you posted on my experience and feedback with this. Thanks a lot for your quick responses.

@MayaGans
Copy link

I'm making a sort of spin off with the app using the alarm dataset that's a lot less dynamic than @paulgovan's, but I used this string manipulation to create multiple evidence nodes that can be used within the cpdist function -- hope this can be of use!

CO <- "HIGH" #would really be input$CO
HIST <- "FALSE" #input$HIST
HRPB <- "" #input$HRBP

# create a string for each evidence node, allow to be left blank 
str1 <<- ifelse(CO == "NA", NA, paste0("(CO == ", "'", CO), "')"))
str2 <<- ifelse(HIST == "NA", NA, paste0("(HIST == ", "'", HIST, "')"))
str3 <<- ifelse(HRBP == "NA", NA, paste0("(HRBP == ", "'", HRBP, "')"))

# Take strings wirth values and paste together
myStr <<- na.omit(c(str1, str2, str3))

# Put &s between strings with values - use this in cpdist
finalstr <<- paste0(myStr, collapse = " & ")

Cheers!

@paulgovan
Copy link
Owner

Thanks for the contribution @MayaGans. I'll try to implement this in the next few days. Would be cool to have this feature.

@paulgovan
Copy link
Owner

I think I may have spoken too soon. After revisiting this issue, the problem I have is not how to capture multiple evidence nodes, but how to create a dynamic UI to capture those inputs. So if your network has 100 nodes, do you want to enter evidence for all of them? Some of them? It gets messy when thinking about all of the different possibilities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants