Upload
jeslyn
View
35
Download
0
Tags:
Embed Size (px)
DESCRIPTION
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. - PowerPoint PPT Presentation
Citation preview
Infer.NETBuilding software with intelligenceJohn Winn and John GuiverMicrosoft Research, Cambridge, UK
VTL03
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…
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
Probability
• “Hello” 70%• “Halo” 20%• “Hall” 5%…
Gestures
> Can be multiple possible interpretations of some measurements
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!
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
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
A Simple Probabilistic Program> I toss two fair coins
> What is the probability both are heads?
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;
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;
Reasoning Backwards
> What is the probability the first coin was heads?
> Suppose I did not get two heads
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;
Two Coins in C#
example
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;
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
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;
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
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…
Two Coins in Infer.NET
example
How Infer.NET Works
firstCoin
Bernoulli(0.5)
secondCoin
Bernoulli(0.5)
bothHeads
&
Normal executionBackwards messages Observe F
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
Biased Coins
10% 50% 90%Probability of heads (p)
FTFFT
TFTTTT
FFFFFT T
10% 50% 90%
Reasoning Backwards
FTFFT
TFTTTT
FFFFFT T
Beta distributions
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
Example : Search Log Analysis
The Click Log
1
2
3
4
T
F
F
T
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
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]);
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];
Click Analysis in Infer.NET
example
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
Inferring Skills
0 10 20 30 40 50Skill Level
Belie
f in
Skill
Leve
l
1st Place2nd Place3rd Place
Game Outcome
DrSlowPlay
SniperEye
Sully
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);
‘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
>>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?
http://research.microsoft.com/infernet
Thank you
http://research.microsoft.com/infernet
YOUR FEEDBACK IS IMPORTANT TO US! Please fill out session evaluation
forms online atMicrosoftPDC.com
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….
© 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.