godai0519 / BayesianNetwork

An implementation of Bayesian Networks Model for pure C++14 (11) later, including probability inference and structure learning method.
MIT License
39 stars 10 forks source link

any example and document(english)? #18

Open andyyuan78 opened 9 years ago

andyyuan78 commented 9 years ago

thanks

godai0519 commented 9 years ago

Thank you for your issue.

Sorry that I can't live up to your expectations. I cannot write them for a while, because I don't have enough time. If I feel like myself later, I will write. so, this issue will not close.

However, code below might be helpful.

thanks,

cookiengineer commented 7 years ago

@godai0519 Can you please add an example.csv file to the example?

This example is hard to understand when you don't know how the data (CSV file) looks like.

It would be awesome to just have a simple CSV file with 10 lines in it, doesn't have to be complicated. That would ease up understanding the usage much much more.

godai0519 commented 7 years ago

Sorry, that example is old. Please use the following instead.

bn::sampler sampler;
sampler.set_filename("samples.csv");
sampler.load_sample(graph.vertex_list());
sampler.make_cpt(graph);

A example of CSV which has 10 nodes is below:

14816 2 1 1 0 2 2 1 1 1 1
41 2 0 0 0 1 2 1 0 2 1
39139 2 2 2 1 2 2 1 1 1 1
1737 2 0 1 0 1 2 1 1 1 2
14601 2 1 2 0 2 2 2 1 1 1
6260 2 0 1 0 1 2 2 1 1 1
60475 0 0 1 0 2 2 1 1 1 1

The first line of the example indicates that there are 14816 samples with X1=2, X2=1, ..., X10=1, where X1,...,X10 are random variables (node) in graph.

Please feel free to reply if there is anything that you don't understand.