41
Infer.NET Building software with intelligence John Winn and John Guiver Microsoft Research, Cambridge, UK VTL03

Infer.NET Building software with intelligence

  • Upload
    jeslyn

  • View
    35

  • Download
    0

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

Page 1: Infer.NET Building software with intelligence

Infer.NETBuilding software with intelligenceJohn Winn and John GuiverMicrosoft Research, Cambridge, UK

VTL03

Page 2: Infer.NET Building software with intelligence

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

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

Probability

• “Hello” 70%• “Halo” 20%• “Hall” 5%…

Gestures

> Can be multiple possible interpretations of some measurements

Page 5: Infer.NET Building software with intelligence

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

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

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

A Simple Probabilistic Program> I toss two fair coins

> What is the probability both are heads?

Page 9: Infer.NET Building software with intelligence

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

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

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

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

Two Coins in C#

example

Page 14: Infer.NET Building software with intelligence

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

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

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

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

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

Two Coins in Infer.NET

example

Page 20: Infer.NET Building software with intelligence

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

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

Biased Coins

10% 50% 90%Probability of heads (p)

FTFFT

TFTTTT

FFFFFT T

Page 23: Infer.NET Building software with intelligence

10% 50% 90%

Reasoning Backwards

FTFFT

TFTTTT

FFFFFT T

Beta distributions

Page 24: Infer.NET Building software with intelligence

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

Example : Search Log Analysis

Page 26: Infer.NET Building software with intelligence

The Click Log

1

2

3

4

T

F

F

T

Page 27: Infer.NET Building software with intelligence

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

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

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

Click Analysis in Infer.NET

example

Page 31: Infer.NET Building software with intelligence

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

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

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

‘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

>>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 36: Infer.NET Building software with intelligence

http://research.microsoft.com/infernet

Page 37: Infer.NET Building software with intelligence

Thank you

http://research.microsoft.com/infernet

Page 38: Infer.NET Building software with intelligence

YOUR FEEDBACK IS IMPORTANT TO US! Please fill out session evaluation

forms online atMicrosoftPDC.com

Page 39: Infer.NET Building software with intelligence

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

© 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