1 / 41

Infer.NET Building software with intelligence

VTL03. Infer.NET Building software with intelligence. John Winn and John Guiver Microsoft Research, Cambridge, UK. Intelligent Software. It should be easier to write software that can adapt, learn and reason…. Word?. Search result?. Who’s the best?. Clicks. Gestures. Game results.

jeslyn
Download Presentation

Infer.NET Building software with intelligence

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. VTL03 Infer.NETBuilding software with intelligence John Winn and John Guiver Microsoft Research, Cambridge, UK

  2. Intelligent Software • It should be easier to write software that can adapt, learn and reason… Word? Search result? Who’s the best? Clicks Gestures Game results

  3. Reasoning Backwards • Need to reason backwards from things we can measure to things we can’t Word? Search result? Who’s the best? Gestures Clicks Game results

  4. Probability • Can be multiple possible interpretations of some measurements • “Hello” 70% • “Halo” 20% • “Hall” 5% … Gestures

  5. Code for Reasoning Backwards Ordinary program Probabilistic program with Infer.NET 20-30 lines of ‘simulation’ code (in any .NET language) Hours, not months! 100s-1000s of lines of code

  6. Some Infer.NET Probabilistic Programs ...in Social Networks Recommended songs Network and music tastes Simulation of sharing of musical tastes between friends ...in Healthcare New understanding of the causes of asthma Electronic health records Clinical simulation of asthma

  7. Some Other Infer.NET Applications • Program verification • Personalisation and recommendation • Data form entry checking • Gene expression analysis • Judgement calibration • Population modelling • Extracting plots of story books • … and many more

  8. A Simple Probabilistic Program • I toss two fair coins • What is the probability both are heads?

  9. C# 'Probabilistic' Program bool firstCoin = random.NextDouble()>0.5; bool secondCoin = random.NextDouble()>0.5; bool bothHeads = firstCoin & secondCoin; … T F T T … F F T T … F F F T

  10. After a Very Large Number of Runs… • ~50% T bool firstCoin = random.NextDouble()>0.5; bool secondCoin = random.NextDouble()>0.5; bool bothHeads = firstCoin & secondCoin; • ~50% F • ~50% T • ~50% F • ~25% T • ~75% F

  11. Reasoning Backwards • Suppose I did not get two heads • What is the probability the first coin was heads?

  12. Probabilistic Program We observe that bothHeads is F bool firstCoin = random.NextDouble()>0.5; bool secondCoin = random.NextDouble()>0.5; bool bothHeads = firstCoin & secondCoin; … T F T T … F F T T … F F F T

  13. Two Coins in C# example

  14. After a Very Large Number of Runs… • ~33% T bool firstCoin = random.NextDouble()>0.5; bool secondCoin = random.NextDouble()>0.5; bool bothHeads = firstCoin & secondCoin; • ~67% F • ~33% T • ~67% F • ~0% T • ~100% F

  15. Multiple Runs Are Very Inefficient • Illustrates how a prob. program works • But we want to reason about complex situations with 1000s of variables e.g. observing 20 binary variables needs ~220 million runs • Is there a practical approach? Infer.NET

  16. Random Variables in Infer.NET T T var firstCoin = Variable.Bernoulli(0.5); var secondCoin = Variable.Bernoulli(0.5); var bothHeads = firstCoin & secondCoin; • 50% • 50% F • 25%

  17. Getting the Distribution of ‘bothHeads’ varengine = newInferenceEngine(); Bernoulli result = engine.Infer<Bernoulli>(bothHeads); doubleprobTrue = result.GetProbTrue(); // ‘probTrue’ is now exactly 0.25

  18. Adding an Observation We observe that bothHeads is F bothHeads.ObservedValue = false; Bernoulli firstDist = engine.Infer<Bernoulli>(firstCoin); double newProb = firstDist.GetProbTrue(); // ‘newProb’ is now exactly 0.333…

  19. Two Coins in Infer.NET example

  20. How Infer.NET Works Bernoulli(0.5) Bernoulli(0.5) firstCoin secondCoin & • Normal execution bothHeads • Backwards messages Observe F

  21. Almost Done with the Coins! • For ‘tossing a coin’ think: • Clicking on a link • Choosing a menu option • Buying a product… • Want to learn the probability of these events • Like having a biased coin

  22. Biased Coins • Probability of heads (p) • 10% • 50% • 90% T T T F T T F T F F T F F F T F T F

  23. Reasoning Backwards • Beta distributions • 10% • 50% • 90% T T T F T T F T F F T F F F T F T F

  24. Reasoning Backwards // a flat Beta distributionvarp = Variable.Beta(1,1); vartoss1 = Variable.Bernoulli(p);toss1.ObservedValue = false; vartoss2 = Variable.Bernoulli(p); toss2.ObservedValue = true; Beta result = engine.Infer<Beta>(p); // gives a Beta curve like the ones// on the last slide F T … …

  25. Example : Search Log Analysis

  26. The Click Log Click Log 1 2 3 4 T F T F

  27. Aaargh! It’s relevant! Imagine One User and One Query Examine appeal Done! N Y Next? Click? Let’s look at the page … … and see if it’s useful Let’s look at the next result … … and see if it’s worth clicking on That looks promising …… let’s click Y N View relevance N Y Next? Relevant? N Y Y Next? varclick = Variable.Bernoulli(appeal[d]); var next = Variable.Bernoulli(0.2); vardoNext = Variable.Bernoulli(0.9); varisRel= Variable.Bernoulli(relevance[d]); N

  28. A Snippet of Infer.NET code // Is user examining this item? examine[d] = examine[d - 1] &(((!click[d - 1]) & nextIfNotClick) |(click[d - 1] & nextIfClick)); // Flip the biased coins! click[d] = examine[d] & Variable.Bernoulli(appeal[d]); isRelevant[d] = click[d] & Variable.Bernoulli(relevance[d]);

  29. Reasoning Backwards Click Log T F T T T F F F F F F T F T T F for(int d = 0; d < nRanks; d++) click[d].ObservedValue = user.clicks[d];

  30. Click Analysis in Infer.NET example

  31. How Good Are You at Halo? • Xbox Live • 12 million players • 2 million matches per day • 2 billion hours of gameplay • The Challenge • Tracking how good each player is to match players of similar skill. • TrueSkill™ • Months of work, 100s of lines of code Old Estimates of Players’ Skills New Estimates of Players’ Skills

  32. 3rd Place 1st Place 2nd Place Inferring Skills Game Outcome SniperEye DrSlowPlay Belief in Skill Level • Sully 0 10 20 30 40 50 Skill Level

  33. Probabilistic Program • // Gaussian random variables for skills • var skill1 = Variable.Gaussian(oldMean1, oldStdDev1); • varskill2 = Variable.Gaussian(oldMean2, oldStdDev2); • varskill3 = Variable.Gaussian(oldMean3, oldStdDev3); • // Players’ performances are centred around their skills • varperf1 = Variable.Gaussian(skill1, beta); • var perf2 = Variable.Gaussian(skill2, beta); • var perf3 = Variable.Gaussian(skill3, beta); • // Outcomes • Variable.ConstrainPositive(perf1 – perf2); • Variable.ConstrainPositive(perf2 - perf3); • // Now we update the players’ skills • var newSkill1 =engine.Infer<Gaussian>(skill1); • varnewSkill2 =engine.Infer<Gaussian>(skill2); • varnewSkill3 =engine.Infer<Gaussian>(skill3);

  34. ‘Language’ Elements of Infer.NET Poisson Beta Gaussian Discrete Dirichlet Gamma Bernoulli Wishart Variable.If Variable.Switch Variable.ForEach Variable.Case Variable.IfNot varbias =Variable.Beta(1,1); varcoin =Variable.Bernoulli(bias); varh =Variable.GaussianFromMeanAndPrecision(m, p); vara = b > c; varz = x + y; Variable<bool>

  35. Sometime in the Future? • varfirstCoin =Variable.Bernoulli(0.5); • varsecondCoin =Variable.Bernoulli(0.5); • varbothHeads = c1 & c2; • bothHeads.ObservedValue = false; • varie = newInferenceEngine(); • Bernoulli result =ie.Infer<Bernoulli>(firstCoin); Infer.NET API Probabilistic language?

  36. http://research.microsoft.com/infernet

  37. Thank you http://research.microsoft.com/infernet

  38. YOUR FEEDBACK IS IMPORTANT TO US! Please fill out session evaluation forms online at MicrosoftPDC.com

  39. Learn More On Channel 9 • Expand your PDC experience through Channel 9 • Explore videos, hands-on labs, sample code and demos through the new Channel 9 training courses channel9.msdn.com/learn Built by Developers for Developers….

More Related