Infer.NET Building software with intelligence
description
Transcript of Infer.NET Building software with intelligence
![Page 1: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/1.jpg)
Infer.NETBuilding software with intelligenceJohn Winn and John GuiverMicrosoft Research, Cambridge, UK
VTL03
![Page 2: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/2.jpg)
Intelligent Software
Search result?Word? Who’s the best?
ClicksGestures Game results
> It should be easier to write software that can adapt, learn and reason…
![Page 3: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/3.jpg)
Reasoning Backwards
Word?
Gestures
> Need to reason backwards from things we can measure to things we can’t
Search result? Who’s the best?
Clicks Game results
![Page 4: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/4.jpg)
Probability
• “Hello” 70%• “Halo” 20%• “Hall” 5%…
Gestures
> Can be multiple possible interpretations of some measurements
![Page 5: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/5.jpg)
Code for Reasoning Backwards
100s-1000s of lines of code
Ordinary program
20-30 lines of ‘simulation’ code (in any .NET language)
Probabilistic program
with Infer.NET
Hours, not months!
![Page 6: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/6.jpg)
Some Infer.NET Probabilistic Programs
Electronic health records
New understandin
g of the causes of asthma
...in Healthcare
...in Social Networks
Clinical simulation of
asthma
Network and
music tastes
Recommended songs
Simulation of sharing of musical tastes between
friends
![Page 7: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/7.jpg)
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
![Page 8: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/8.jpg)
A Simple Probabilistic Program> I toss two fair coins
> What is the probability both are heads?
![Page 9: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/9.jpg)
C# 'Probabilistic' Program
T F T
F
T
T FT
F T FF
…
…
…
bool firstCoin = random.NextDouble()>0.5;
bool secondCoin = random.NextDouble()>0.5;
bool bothHeads = firstCoin & secondCoin;
![Page 10: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/10.jpg)
After a Very Large Number of Runs…
TF
~50%~50%
TF
~50%~50%
TF
~25%~75%
bool firstCoin = random.NextDouble()>0.5;
bool secondCoin = random.NextDouble()>0.5;
bool bothHeads = firstCoin & secondCoin;
![Page 11: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/11.jpg)
Reasoning Backwards
> What is the probability the first coin was heads?
> Suppose I did not get two heads
![Page 12: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/12.jpg)
Probabilistic Program
T F T
F
T
T FT
F T FF
…
…
…
We observe that bothHeads is F
bool firstCoin = random.NextDouble()>0.5;
bool secondCoin = random.NextDouble()>0.5;
bool bothHeads = firstCoin & secondCoin;
![Page 13: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/13.jpg)
Two Coins in C#
example
![Page 14: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/14.jpg)
After a Very Large Number of Runs…
TF
~33%~67%
TF
~33%~67%
TF
~0%~100%
bool firstCoin = random.NextDouble()>0.5;
bool secondCoin = random.NextDouble()>0.5;
bool bothHeads = firstCoin & secondCoin;
![Page 15: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/15.jpg)
Multiple Runs Are Very Inefficient
> Is there a practical approach?
Infer.NET
> 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
![Page 16: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/16.jpg)
Random Variables in Infer.NET
50%T
50%T
25%F
var firstCoin = Variable.Bernoulli(0.5);
var secondCoin = Variable.Bernoulli(0.5);
var bothHeads = firstCoin & secondCoin;
![Page 17: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/17.jpg)
Getting the Distribution of ‘bothHeads’var engine = new InferenceEngine();
Bernoulli result = engine.Infer<Bernoulli>(bothHeads);
double probTrue = result.GetProbTrue();// ‘probTrue’ is now exactly 0.25
![Page 18: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/18.jpg)
Adding an ObservationWe observe that bothHeads is F
bothHeads.ObservedValue = false;
Bernoulli firstDist = engine.Infer<Bernoulli>(firstCoin);
double newProb = firstDist.GetProbTrue();// ‘newProb’ is now exactly 0.333…
![Page 19: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/19.jpg)
Two Coins in Infer.NET
example
![Page 20: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/20.jpg)
How Infer.NET Works
firstCoin
Bernoulli(0.5)
secondCoin
Bernoulli(0.5)
bothHeads
&
Normal executionBackwards messages Observe F
![Page 21: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/21.jpg)
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
![Page 22: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/22.jpg)
Biased Coins
10% 50% 90%Probability of heads (p)
FTFFT
TFTTTT
FFFFFT T
![Page 23: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/23.jpg)
10% 50% 90%
Reasoning Backwards
FTFFT
TFTTTT
FFFFFT T
Beta distributions
![Page 24: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/24.jpg)
Reasoning Backwards
…
T
F
…
// a flat Beta distributionvar p = Variable.Beta(1,1);
var toss1 = Variable.Bernoulli(p);toss1.ObservedValue = false;
var toss2 = Variable.Bernoulli(p);toss2.ObservedValue = true;
Beta result = engine.Infer<Beta>(p);// gives a Beta curve like the ones// on the last slide
![Page 25: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/25.jpg)
Example : Search Log Analysis
![Page 26: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/26.jpg)
The Click Log
1
2
3
4
T
F
F
T
![Page 27: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/27.jpg)
Let’s look at the next result …… and see if it’s worth clicking
on
Let’s look at the page …… and see if it’s useful
Aaargh!It’s relevant!
Done!That looks promising …
… let’s click
Imagine One User and One Query
Click?
Examine
View
Next?
Relevant?
Next?
Next?
Y
N
N
N
N
N
Y
Y
Y
Y
var click = Variable.Bernoulli (appeal[d]);var next = Variable.Bernoulli (0.2); var doNext = Variable.Bernoulli (0.9); var isRel = Variable.Bernoulli (relevance[d]);
appeal
relevance
![Page 28: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/28.jpg)
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]);
![Page 29: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/29.jpg)
Reasoning Backwards
T
T
F
F
F
F
F
T
T
F
F
T
T
T
F
F
for (int d = 0; d < nRanks; d++) click[d].ObservedValue = user.clicks[d];
![Page 30: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/30.jpg)
Click Analysis in Infer.NET
example
![Page 31: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/31.jpg)
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
Gamertag ScoreSully 25SniperEye 22DrSlowPlay 17
New Estimates of
Players’ Skills
Old Estimates of
Players’ Skills
![Page 32: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/32.jpg)
Inferring Skills
0 10 20 30 40 50Skill Level
Belie
f in
Skill
Leve
l
1st Place2nd Place3rd Place
Game Outcome
DrSlowPlay
SniperEye
Sully
![Page 33: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/33.jpg)
Probabilistic Program// Gaussian random variables for skills var skill1 = Variable.Gaussian(oldMean1, oldStdDev1);var skill2 = Variable.Gaussian(oldMean2, oldStdDev2);var skill3 = Variable.Gaussian(oldMean3, oldStdDev3);// Players’ performances are centred around their skillsvar perf1 = Variable.Gaussian(skill1, beta);var perf2 = Variable.Gaussian(skill2, beta);var perf3 = Variable.Gaussian(skill3, beta);// OutcomesVariable.ConstrainPositive(perf1 – perf2);Variable.ConstrainPositive(perf2 - perf3);// Now we update the players’ skillsvar newSkill1 = engine.Infer<Gaussian>(skill1);var newSkill2 = engine.Infer<Gaussian>(skill2);var newSkill3 = engine.Infer<Gaussian>(skill3);
![Page 34: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/34.jpg)
‘Language’ Elements of Infer.NET
Variable<bool>
Variable.If
Variable.Case Variable.IfNot
Variable.SwitchVariable.ForEach
var coin = Variable.Bernoulli(bias);
var bias = Variable.Beta(1,1);
var h = Variable.GaussianFromMeanAndPrecision(m, p); var z = x +
y;var a = b > c;
Gaussian Dirichlet
Beta
BernoulliGamma
Poisson
Wishart
Discrete
![Page 35: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/35.jpg)
>>FUTURESometime in the Future?
var firstCoin = Variable.Bernoulli(0.5);
var secondCoin = Variable.Bernoulli(0.5);
var bothHeads = c1 & c2;
bothHeads.ObservedValue = false;
var ie = new InferenceEngine();
Bernoulli result = ie.Infer<Bernoulli>(firstCoin);
Infer.NET API
Probabilistic
language?
![Page 37: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/37.jpg)
Thank you
http://research.microsoft.com/infernet
![Page 38: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/38.jpg)
YOUR FEEDBACK IS IMPORTANT TO US! Please fill out session evaluation
forms online atMicrosoftPDC.com
![Page 39: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/39.jpg)
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/learnBuilt by Developers for Developers….
![Page 40: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/40.jpg)
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
![Page 41: Infer.NET Building software with intelligence](https://reader035.fdocuments.net/reader035/viewer/2022062501/56816933550346895de08799/html5/thumbnails/41.jpg)