Closed jacowp357 closed 4 years ago
I'm new to c# and infer.net, perhaps starting with a simpler example in my own code will help me figure it out.
I would like to know a simple way to create the factor p(y|x,z) in my code below:
Here is a drawing of the graph I want to experiment with:
The simplest way is to use boolean variables along with logical operators:
var y = ((x == z) == Variable.Bernoulli(0.1));
var r = (y == Variable.Bernoulli(0.8));
It works thanks! However, for VMP it gives the following error:
"Unhandled exception. Microsoft.ML.Probabilistic.Compiler.CompilationFailedException: MessageTransform failed with 2 error(s) and 0 warning(s): Error 0: This model is not supported with VariationalMessagePassing due to Factor.AreEqual(bool areEqual, bool a, bool b). Try using a different algorithm or expressing the model differently in Factor.AreEqual(vbool2_use, vbool3_use) Details: Variational Message Passing does not support an AreEqual factor with fixed output. using parameter types: [areEqual] bool,[a] Bernoulli,[to_a] Bernoulli,[b] Bernoulli,[to_b] Bernoulli,[result] Bernoulli"
How can the model be expressed differently in this case?
Another way, that VMP will like, is to branch on y:
var r = Variable.New<bool>();
using(Variable.If(y)) {
r.SetTo(Variable.Bernoulli(0.8));
}
using(Variable.IfNot(y)) {
r.SetTo(Variable.Bernoulli(0.2));
}
How can I interpret the branching on y? Did the structure of the graph change? How did this change make it possible for VMP?
Infer.NET can show you the factor graph. The theory behind branching, how it changes the factor graph, and how it interacts with message-passing inference algorithms is described in the paper Gates: A Graphical Notation for Mixture Models.
Here is the factor graph generated with ShowFactorGraph
.
I'm not sure how to translate this graph to the gate notation in the paper you shared (maybe Figure 1 (b)?). Please see my attempt attached. I'm not sure if random variable y should be included in the gate?
In the generated graph, y is the gate condition, and the other two subgraphs leading to "False" (which is r) are inside the gates. y is not inside the gates, nor connected to anything inside the gates.
I have edited the Clinical trial tutorial (which is similar to the model above) to discuss how the factor graph is displayed.
I'm running Visual Studio for Mac (8.3.10) and battling with the windows forms etc. Is there a workaround to getting the DGML format? Or other requirements I need to install perhaps?
You can now get the graph in DGML format on any platform.
I would like to get help with creating a very simple discrete model like the Monty Hall problem without parameter learning? Not sure if this is the appropriate channel to ask this.