/
Infer.NET Infer.NET

Infer.NET - PowerPoint Presentation

luanne-stotts
luanne-stotts . @luanne-stotts
Follow
401 views
Uploaded On 2016-05-12

Infer.NET - PPT Presentation

Building software with intelligence John Winn and John Guiver Microsoft Research Cambridge UK VTL03 Intelligent Software Search result Word Whos the best Clicks Gestures Game results ID: 317103

var variable infer bernoulli variable var bernoulli infer firstcoin bool net amp secondcoin bothheads click gaussian beta random nextdouble probabilistic result engine

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Infer.NET" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Infer.NETBuilding software with intelligence

John Winn and John GuiverMicrosoft Research, Cambridge, UK

VTL03Slide2

Intelligent Software

Search result?

Word?

Who’s the best?

Clicks

Gestures

Game results

It should be

easier

to write software that can adapt, learn and reason…Slide3

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 resultsSlide4

Probability

“Hello” 70%

“Halo” 20%

“Hall” 5%

Gestures

Can be

multiple

possible interpretations of some measurementsSlide5

Code for Reasoning Backwards

100s-1000s of lines of code

Ordinary program

2

0-30 lines of ‘simulation’ code

(in any .NET language)

Probabilistic

program

with Infer.NET

Hours, not months!Slide6

Some Infer.NET Probabilistic Programs

Electronic health records

New understanding 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 friendsSlide7

Some Other Infer.NET Applications

Program verificationPersonalisation and recommendationData form entry checkingGene expression analysis

Judgement calibration

Population modelling

Extracting plots of story books… and many moreSlide8

A Simple Probabilistic Program

I toss two fair coins

What is the probability both are heads?Slide9

C# 'Probabilistic' Program

T

F

T

F

T

T

F

T

F

T

F

F

bool

firstCoin =

random.NextDouble

()>0.5;

bool

secondCoin =

random.NextDouble

()>0.5;

bool

bothHeads =

firstCoin & secondCoin;Slide10

After a Very Large Number of Runs…

T

F

~50%

~50%

T

F

~50%

~50%

T

F

~25%

~75%

bool

firstCoin =

random.NextDouble

()>0.5;

bool

secondCoin =

random.NextDouble

()>0.5;

bool

bothHeads =

firstCoin & secondCoin;Slide11

Reasoning Backwards

What is the probability the first coin was heads?

Suppose I did

not

get two headsSlide12

Probabilistic Program

T

F

T

F

T

T

F

T

F

T

F

F

We

observe

that bothHeads is

F

bool

firstCoin =

random.NextDouble()>0.5;

bool

secondCoin =

random.NextDouble()>0.5;

bool

bothHeads =

firstCoin & secondCoin;Slide13

Two Coins in C#

exampleSlide14

After a Very Large Number of Runs…

T

F

~33%

~67%

T

F

~33%

~67%

T

F

~0%

~100%

bool

firstCoin =

random.NextDouble()>0.5;

bool

secondCoin =

random.NextDouble()>0.5;

bool

bothHeads =

firstCoin & secondCoin;Slide15

Multiple Runs Are Very Inefficient

Is there a practical approach?

I

nfer.NET

Illustrates how a prob.

p

rogram works

But we want to reason about

complex

situations with 1000s of variables

e.g. observing 20 binary variables needs

~

2

20

million

runsSlide16

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;Slide17

Getting the Distribution of ‘bothHeads’

var

engine =

new

InferenceEngine

();

Bernoulli

result =

engine.Infer

<

Bernoulli

>(bothHeads);

double

probTrue = result.GetProbTrue();// ‘probTrue’ is now exactly 0.25Slide18

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…Slide19

Two Coins in Infer.NET

exampleSlide20

How Infer.NET Works

firstCoin

Bernoulli(0.5)

secondCoin

Bernoulli(0.5)

bothHeads

&

Normal execution

Backwards messages

Observe

FSlide21

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

coinSlide22

Biased Coins

10%

50%

90%

Probability of heads (

p)

F

T

F

F

T

T

F

T

T

T

T

F

F

F

F

F

T

TSlide23

10%

50%

90%

Reasoning Backwards

F

T

F

F

T

T

F

T

T

T

T

F

F

F

F

F

T

T

Beta distributionsSlide24

Reasoning Backwards

T

F

// a flat Beta distribution

var

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 slideSlide25

Example : Search Log AnalysisSlide26

The Click Log

1

2

3

4

Click

Log

T

F

F

TSlide27

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

relevanceSlide28

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]);Slide29

Reasoning Backwards

T

T

F

F

F

F

F

T

T

F

F

T

T

T

F

F

Click

Log

for

(

int

d = 0; d < nRanks; d++)

click[d

].

ObservedValue

=

user.clicks

[d];Slide30

Click Analysis in Infer.NET

exampleSlide31

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

Score

Sully

25

SniperEye

22

DrSlowPlay

17

New Estimates of Players’ Skills

Old Estimates of Players’ SkillsSlide32

Inferring Skills

0

10

20

30

40

50

Skill Level

Belief in Skill Level

1

st

Place

2

nd

Place

3

rd

Place

Game

Outcome

DrSlowPlay

SniperEye

SullySlide33

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’ skills

var

newSkill1 =

engine.Infer

<

Gaussian

>(skill1);

var

newSkill2

=

engine.Infer

<

Gaussian

>(skill2);

var

newSkill3

=

engine.Infer

<

Gaussian

>(

skill3);Slide34

‘Language’ Elements of Infer.NET

Variable

<

bool

>

Variable

.If

Variable

.Case

Variable

.IfNot

Variable

.Switch

Variable

.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

Bernoulli

Gamma

Poisson

Wishart

DiscreteSlide35

Sometime 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?Slide36

http://research.microsoft.com/infernetSlide37

Thank you

http://research.microsoft.com/infernetSlide38

YOUR FEEDBACK IS IMPORTANT TO US!

Please fill out session evaluation forms online at

MicrosoftPDC.comSlide39

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….Slide40
Slide41