Created
March 5, 2015 14:48
-
-
Save haluk/cb1e237bf4337d3d7912 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(int argc, char* argv[]) { | |
BNLearner learner(argv[1]); | |
learner.useGreedyHillClimbing(); | |
gum::BayesNet<float> bn = learner.learnBN(); | |
cout << "Structure learning" << endl; | |
cout << "------------------" << endl; | |
const gum::Potential<float>& p1 = bn.cpt(bn.idFromName("lung_cancer?")); | |
gum::Instantiation II ( p1 ); | |
for ( II.setFirst(); ! II.end(); ++II) | |
cout << p1[II] << endl; | |
cout << "Gibbs Inference" << endl; | |
cout << "---------------" << endl; | |
gum::GibbsInference<float> inf ( bn ); | |
inf.setVerbosity ( true ); | |
inf.makeInference(); | |
const gum::Potential<float>& p2 = inf.posterior(bn.idFromName("lung_cancer?")); | |
gum::Instantiation III ( p2 ); | |
for ( III.setFirst(); ! III.end(); ++III) | |
cout << p2[III] << endl; | |
inf.addHardEvidence(bn.idFromName("smoking?"), 1); | |
inf.makeInference(); | |
cout << "After new evidence" << endl; | |
cout << "------------------" << endl; | |
const gum::Potential<float>& p3 = inf.posterior(bn.idFromName("lung_cancer?")); | |
gum::Instantiation IIII ( p3 ); | |
for ( IIII.setFirst(); ! IIII.end(); ++IIII) | |
cout << p3[III] << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment