88
ARE YOU BETTER THAN A COIN TOSS? BY JOHN OLIVER AND RICHARD WARBURTON

Are you better than a coin toss? - Richard Warbuton & John Oliver (jClarity)

Embed Size (px)

DESCRIPTION

Presented at JAX London 2013 So you’re a big data and distributed systems “expert”, you’ve collected 500 billion data points, thrown it into sci-lib-of-the-week, you’re using Hadoop, backing onto those cool AWS GPU instances, let it grind away for days and it's spit out the answer to life the universe and everything. But is it really better than a coin toss? How do you validate whether your data analysis algorithm works? Are you learning a solution to your problems or just the data you already have? What problems can you encounter when analysing your data?

Citation preview

Page 1: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

ARE YOU BETTERTHAN A COIN TOSS?

BY JOHN OLIVER AND RICHARD WARBURTON

Page 2: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)
Page 3: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

WHO ARE WE?

Page 4: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

Why you should care

The Fundamentals

Practical Problems

Applying the Theory

Page 5: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)
Page 6: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)
Page 7: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)
Page 8: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

'EXPERTS" AREN'T VERY GOOD

Page 9: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)
Page 10: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

BIG DATA SOLVESALL KNOWNPROBLEMS

Page 11: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

BIG DATA SOLVESALL KNOWNPROBLEMS

... HELPS

Page 12: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

VALIDATION =TESTS FOR DATA

Page 13: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

FUNDAMENTALS

Page 14: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

NULL HYPOTHESISUntil proven otherwise there is no relationship

between phenomena

Page 15: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

WHEN YOU HEAR "WOLF!" THERE IS A WOLFNEARBY

Cry "Wolf!" Stay QuietWolf Nearby Ok False

NegativeIts really achicken!

FalsePositive

Ok

Page 16: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

WHY IS THIS IMPORTANT?

Page 17: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

It is better that ten guilty personsescape than that one innocent suffer

- William Blackstone

Page 18: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)
Page 19: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

STATIC ANALYSIS

Page 20: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

COST BENEFIT ANALYSISCosts a lot to jail an innocent manCosts very little to show someone aninappropriate houseCredibility, Liberty, Morality are also costs

Page 21: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

CHOOSE THE RIGHT MEASUREMENTThere's more than one concept of accuracy

Page 22: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

RECALL

Recall =number of true positives

number of actually true values

Recall =tp

+tp fn

Also called True Positive Rate or Sensitivity

Page 23: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

PRECISION

Precision =number of true positives

predicted true value

Precision =tp

+tp fp

Also called Positive Predicted Value

Page 24: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

=Fβ

(1 + ) ⋅β2 tp

(1 + ) ⋅ + ⋅ +β2 tp β2 fn fp

F MEASURE

Don't worry about the formula!

Page 25: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

CASE STUDY: MEMORY LEAKSAbout ~10% of our dataset had memory leaks

Predict "never leaks memory" ~= 0.9 accuracy,but F1 = 0

Our algorithm ~= 0.9 accuracy and F1 ~= 0.9

Page 26: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

PROBLEM: RELIABILITY OF MEASUREMENT

Page 27: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

RULE OF THUMBIf the graph looks like random noise, it probably

is random noise.

Page 28: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

SOLUTION: CHECK YOUR DATA

Low Standard Deviation

σ = ( −1N

∑i=1

N

xi x̄)2

− −−−−−−−−−−−−⎷

Coefficient of V ariation =σ

Mean

Page 29: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

CAVEAT: NON-NORMAL DISTRIBUTONS

Page 30: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)
Page 31: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

GO MAD (MEDIAN ABSOLUTE DEVIATION)MAD = media (| − media ( )|)ni Xi nj Xj

Page 32: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

PROBLEM: EXPERIMENTAL FLUKES

Page 33: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

IS YOUR A/B TEST A HEISEN TEST?

Page 34: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

SOLUTION: P-VALUE

Many tests: eg Chi-Squared or Student's T

How many times do you need to roll heads beforeyou know your coin isn't biased?

Page 35: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

SCIENCE WORKS - B****ES!

Page 36: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

PRACTICALPROBLEMS

Page 37: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

PROBLEM: FALSE PROPHETS

Page 38: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

I'M AN EXPERT, LISTEN TO ME!

Page 39: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

SOLUTION: ESTABLISH GOALS AND HYPOTHESISTHEN TEST SOLUTIONS

Page 40: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

PROBLEM: CODE QUALITYThe math works :-) the code does not

:-(@headinthebox

Page 41: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

GROWTH IN A TIME OF DEBT

Page 42: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

SOLUTION: SOFTWARE ENGINEERING PRACTICES

Page 43: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

Everyone Lies- House

Page 44: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

SOLUTION: UNDERSTAND BIASESAND DESIGN AROUND THEM

Page 45: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

Gay couples should have an equalright to get married, not just to have

civil partnershipsPopulus: 65% vs 27%

Marriage should continue to bedefined as a life-long exclusive

commitment between a man and awoman

Comres: 22% vs 70%

Page 46: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

ACQUIESCENCE BIASAnswer yes

Page 47: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

REMOVAL OF PARTICULAR ADVERTISING AND SPONSORSHIP BANS

FOR: 1045 AGAINST: 731 ABSTAIN: 121 Motion Carried

MAINTAINING AN ETHICAL UNION BY REAFFIRMING ADVERTISING ANDSPONSORSHIP BANS

FOR: 858AGAINST: 755ABSTAIN: 166Motion Carried

Page 48: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

SOLUTION: PHRASE QUESTIONS NEUTRALLYAnd only have one question

Page 49: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

SOCIAL DESIRABILITYPoor people overestimate their income, rich

people under estimate it.

Page 50: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

SOLUTIONSAnonymisationConfidentialityRandomized ResponseBogus Pipeline

Page 51: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

BIAS TOWARDS THE FIRSTANSWER OF A QUESTION

Make sure to randomise the order of answers

Page 52: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

PROBLEM: CORRELATION DOESN’T IMPLYCAUSALITY

Page 53: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

DATABASE AND NETWORKACTIVITY CORRELATING

Performance Diagnosis: was actually a GarbageCollection Problem.

Page 54: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

SOLUTION: DOMAIN KNOWLEDGE

Page 55: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)
Page 56: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

SOLUTIONSUse domain knowledge - ask PilotsStratified sample setsMeasure outcomes - are planes survivingmore?

Page 57: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

BE RIGOROUS

Page 58: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

APPLYING THETHEORY

Page 59: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

CORRELATIONA MEASURE OF THE STRENGTH OF DEPENDENCE BETWEEN TWO VARIABLES

Page 60: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

PEARSON CORRELATION= =ρX,Y

cov(X, Y )σXσY

E[(X − )(Y − )]μX μY

σXσY

Err...Just look it up

(Assumes linear relationship)

Page 61: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

Range Strength<0.4 Weak/No Correlation<0.7 Some Correlation>0.7 Strong Correlation

Page 62: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

CASE STUDY: PERFORMANCE PROBLEM WITH HIGHSYSTEM TIME

Hypothesis: caused by Disk I/O

Page 63: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

Correlation Strength: 0.78453

Page 64: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

MACHINE LEARNINGApplication of statistics to learn a relationship

Page 65: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

HOW MANY CLUSTERS?

Page 66: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

HOW MANY CLUSTERS?

Page 67: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

HOW MANY CLUSTERS?

Page 68: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

SOLUTION: ELBOW ESTIMATORS

Page 69: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

FITTING

Page 70: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

FITTING

Page 71: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

SOLUTION:CROSS VALIDATION

Page 72: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)
Page 73: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

CHOOSE CROSS VALIDATION DATA WISELY

Page 74: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

SELF VALIDATINGEnsemble methods - Train lots of weak classifiers

and merge

Page 75: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

RANDOM FOREST AND BAGGINGDivide the data into bootstrap sets

Use the rest for calculating error

Page 76: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

LEARNING CURVES

Page 77: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

UNDER-FITTING (BIAS)

Page 78: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

OVER-FITTING (VARIANCE)

Page 79: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

HOW MUCH IS TOO MUCH?

Page 80: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

ACCURACY FOR DIFFERENT TREE SIZES

Page 81: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

F1 FOR DIFFERENT TREE SIZES

Page 82: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)
Page 83: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)
Page 84: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

MONITOR PRODUCTION DATA...IT CHANGESDoes it look like the same data that you learnt

with?

Page 85: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

A/B TEST NEW SYSTEMSSatisfaction/Profit/Traffic...

Page 86: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

COMMON THREADSTraining set errors are misleadingCross Validation, Production MonitoredValues are the ones that really matterVisualise and compare these errors

Page 87: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

CONCLUSIONAnalytics are increasingly importantWide variety of statistical and practical tips toget them rightHave fun and Best of luck!

Page 88: Are you better than a coin toss?  - Richard Warbuton & John Oliver (jClarity)

@johno_oliver @RichardWarburto

QUESTIONS?http://insightfullogic.com