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

Search result?Word?Who’s the best? ClicksGesturesGame results.

Dec 17, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Search result?Word?Who’s the best? ClicksGesturesGame results.

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

VTL03

Page 2: Search result?Word?Who’s the best? ClicksGesturesGame results.

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: Search result?Word?Who’s the best? ClicksGesturesGame results.

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: Search result?Word?Who’s the best? ClicksGesturesGame results.

Probability

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

Gestures

> Can be multiple possible interpretations of some measurements

Page 5: Search result?Word?Who’s the best? ClicksGesturesGame results.

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: Search result?Word?Who’s the best? ClicksGesturesGame results.

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: Search result?Word?Who’s the best? ClicksGesturesGame results.

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: Search result?Word?Who’s the best? ClicksGesturesGame results.

A Simple Probabilistic Program

> I toss two fair coins

> What is the probability both are heads?

Page 9: Search result?Word?Who’s the best? ClicksGesturesGame results.

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: Search result?Word?Who’s the best? ClicksGesturesGame results.

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;

Page 11: Search result?Word?Who’s the best? ClicksGesturesGame results.

Reasoning Backwards

> What is the probability the first coin was heads?

> Suppose I did not get two heads

Page 12: Search result?Word?Who’s the best? ClicksGesturesGame results.

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: Search result?Word?Who’s the best? ClicksGesturesGame results.

Two Coins in C#

example

Page 14: Search result?Word?Who’s the best? ClicksGesturesGame results.

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;

Page 15: Search result?Word?Who’s the best? ClicksGesturesGame results.

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: Search result?Word?Who’s the best? ClicksGesturesGame results.

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: Search result?Word?Who’s the best? ClicksGesturesGame results.

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: Search result?Word?Who’s the best? ClicksGesturesGame results.

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…

Page 19: Search result?Word?Who’s the best? ClicksGesturesGame results.

Two Coins in Infer.NET

example

Page 20: Search result?Word?Who’s the best? ClicksGesturesGame results.

How Infer.NET Works

firstCoin

Bernoulli(0.5)

secondCoin

Bernoulli(0.5)

bothHeads

&

Normal executionBackwards messages

Observe F

Page 21: Search result?Word?Who’s the best? ClicksGesturesGame results.

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: Search result?Word?Who’s the best? ClicksGesturesGame results.

Biased Coins

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

FTFFT

TFTTTT

FFFFFT T

Page 23: Search result?Word?Who’s the best? ClicksGesturesGame results.

10% 50% 90%

Reasoning Backwards

FTFFT

TFTTTT

FFFFFT T

Beta distributions

Page 24: Search result?Word?Who’s the best? ClicksGesturesGame results.

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: Search result?Word?Who’s the best? ClicksGesturesGame results.

Example : Search Log Analysis

Page 26: Search result?Word?Who’s the best? ClicksGesturesGame results.

The Click Log

1

2

3

4

T

F

F

T

Page 27: Search result?Word?Who’s the best? ClicksGesturesGame results.

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: Search result?Word?Who’s the best? ClicksGesturesGame results.

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: Search result?Word?Who’s the best? ClicksGesturesGame results.

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: Search result?Word?Who’s the best? ClicksGesturesGame results.

Click Analysis in Infer.NET

example

Page 31: Search result?Word?Who’s the best? ClicksGesturesGame results.

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

codeGamertag Score

Sully 25

SniperEye 22

DrSlowPlay 17

New Estimates of

Players’ Skills

Old Estimates of

Players’ Skills

Page 32: Search result?Word?Who’s the best? ClicksGesturesGame results.

Inferring Skills

0 10 20 30 40 50

Skill Level

Belie

f in

Skill

Level

1st Place

2nd Place

3rd Place

Game Outcome

DrSlowPlay

SniperEye

Sully

Page 33: Search result?Word?Who’s the best? ClicksGesturesGame results.

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: Search result?Word?Who’s the best? ClicksGesturesGame results.

‘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: Search result?Word?Who’s the best? ClicksGesturesGame results.

>>FUTURE

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?

Page 36: Search result?Word?Who’s the best? ClicksGesturesGame results.

http://research.microsoft.com/infernet

Page 37: Search result?Word?Who’s the best? ClicksGesturesGame results.

Thank you

http://research.microsoft.com/infernet

Page 38: Search result?Word?Who’s the best? ClicksGesturesGame results.

YOUR FEEDBACK IS IMPORTANT TO US!

Please fill out session evaluation

forms online atMicrosoftPDC.com

Page 39: Search result?Word?Who’s the best? ClicksGesturesGame results.

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: Search result?Word?Who’s the best? ClicksGesturesGame results.

© 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: Search result?Word?Who’s the best? ClicksGesturesGame results.