Creating a Bayesian Network from a DAG RRS feed

  • Question

  • I'm starting with a DAG with CPTs. Is there a relatively easy way to convert this into a Bayesian Network with Infer.NET?

    I looked at the AddChildFrom___Parents methods from the WetGrassSprinkerRain example, is this the only way to add child objects in a Bayesian network? It doesn't scale very well if I can have any amount of parent nodes. 

    I am able to do it by hand using something like this... (this is just a bit of the code) but I need to automate the process. Any ideas? Surely somebody has done this before.

     Variable<int> Burglary = Variable.Discrete(0.999, 0.001).Named("burglary");
                Variable<int> Lightning = Variable.Discrete(0.98, 0.02).Named("lightning");
                Variable<int> Sensor = Variable.New<int>().Named("sensor");
                using(Variable.Case(Burglary, 1))
                    using (Variable.Case(Lightning, 1))
                         Sensor.SetTo(Variable.Discrete( 0.1,0.9));
                    using (Variable.Case(Lightning, 0))
                         Sensor.SetTo(Variable.Discrete( 0.1 ,0.9 ));

    Saturday, July 11, 2015 7:42 PM

All replies

  • Do you mean something like Variable.Switch?


    Saturday, July 11, 2015 9:49 PM
  • From the description, that sounds like what I need. I don't  know how to use it, I'll look into it soon.
    Saturday, July 11, 2015 10:05 PM
  • I've just been reading up on everything available in Infer.NET and I am very confused and have NO idea where to begin.
    Sunday, July 12, 2015 1:14 AM
  • If all of the entries of the CPTs are given in advance, then the code you've posted is the right way to construct the model.  Automating the steps in that code is more of a C# question (i.e. how to write loops and recursion) than an Infer.NET question. The main subtlety is that you cannot use the 'using' construct if you are automating. See the alternative to 'using' at Branching on variables to create mixture models.
    Sunday, July 12, 2015 9:27 AM