Infer.NET user guide : Tutorials and examples ## Wet grass/sprinkler/rain exampleThis example shows how to construct a discrete Bayesian network in Infer.NET
and how to learn the parameters of the model (the conditional probability
tables) from data. You can find the code for this example in the Although all the variables in this example can only take on two values, the
code is written in a way that is easily extendable to multiple states. The model
is encapsulated in a class There are three modes of operation: - The parameters are exactly known - in this case the priors on the parameters are irrelevant as the parameters are directly observed. We can then query the model in a variety of ways.
- The parameters are unknown, and we want to infer the parameters from observations on the primary variables
- The parameters are known with uncertainty (for example through Bayesian inference), and we want to query the model in the presence of that uncertainty
These 3 cases are called in succession in the main program for this example. (1) and (3) are just illustrated for querying about Prob(Rain) under various assumptions; similar queries can be built up straightforwardly. A simpler less general implementation of this model, which does not address parameter learning, can be found on the community forum. Here is a factor graph of this model: |