Infer.NET

I was on vacation last week so I decided to have some fun with Infer.Net.  As someone interested in F#/Machine learning, Infer.Net seemed like a cool side project.  I was not disappointed.  I downloaded the most recent bits (though no NuGet) and wired up a basic problem of determining the probability of 2 even-sided coins to both come up heads:

  1. Console.WriteLine("Start");
  2.  
  3. Variable<bool> firstCoin = Variable.Bernoulli(0.5);
  4. Variable<bool> secondCoin = Variable.Bernoulli(0.5);
  5. Variable<bool> bothHeads = firstCoin & secondCoin;
  6.  
  7. InferenceEngine engine = new InferenceEngine();
  8. Console.WriteLine("Probability both coins are heads: " + engine.Infer(bothHeads));
  9.  
  10. Console.WriteLine("End");
  11. Console.ReadKey();

 

Sure enough:

image

I can’t wait to dig into the other tutorials and then apply the inference to some of the real data sets I have collected…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: