SlideShare a Scribd company logo
1 of 21
Download to read offline
Thompson Sampling for Machine Learning
R.J. Mak
Greenhouse Group
PyData Amsterdam 2018
May, 26, 2018
Introduction
Group of online marketing
agencies, part of GroupM
Tech Hub
Creative Hub
Data Hub
Data Science Team
Data Technologist Team
Data Insights Team
Consumer Experience
Marketing Team
Multi-Armed Bandit Problem
How to optimally insert
coins in slot machines when
reward distributions of each
machine are unknown?
Exploitation vs. exploration
tradeoff
Applications
Any setting where data
(observations) are costly.
Pretty much any data
science project,
underemphasized.
Deep learning: most focus
on cases where data is
(nearly) abundant.
Classical examples:
Finance
Testing in online
marketing (websites, ads)
Budget allocation R&D
Clinical trials
Applications
Thompson Sampling: some history
Formulated by Thompson in 1933.
Allied scientists in World War II, proposed to drop the
Multi-armed bandit problem over Germany so that German
scientists could also waste their time on it.
1997 proof of convergence.
Asymptotic convergence results for contextual bandits were
published in 2011.
2012 proven to be optimal for the case of Bernoulli rewards
(Lai and Robbins lower bound for the cumulative regret).
Thompson Sampling
Choosing the action that
maximizes the expected
reward with respect to a
randomly drawn belief.
Example of three slot
machines, equal reward,
probability of winning?
Construct reward
distribution. (Beta
distribution).
Sample from those
distributions to choose the
next slot machine.
Thompson sampling using numpy
1 import numpy as np
2
3 plays = np.array([100, 20, 20])
4 wins = np.array([32, 8, 5])
5 num_samples = 1000000
6
7 p_A_sample = np.random.beta(wins[0], plays[0] - wins[0], num_samples)
8 p_B_sample = np.random.beta(wins[1], plays[1] - wins[1], num_samples)
9 p_C_sample = np.random.beta(wins[2], plays[2] - wins[2], num_samples)
10
11 mab_wins = np.array([0.0, 0.0, 0.0])
12
13 for i in range(num_samples):
14 winner = np.argmax([p_A_sample[i], p_B_sample[i], p_C_sample[i]])
15 mab_wins[winner] += 1
16
17 mab_wins = mab_wins / num_samples
18
19 print(mab_wins)
Prediction probabilities vs. prediction distributions
Prediction probabilities and prediction distributions both say
something about uncertainty, what’s the difference?
In the example of object detection, the probabilities are point
estimates of how likely the thing in the picture is a certain
object, for that specific picture. It captures the uncertainty
from the input image.
However, it does not capture the uncertainty from the data
used to train the model. This is what we want to capture with
a prediction distribution.
Prediction probabilities vs. prediction distributions
Traditional (frequentist) clinical trial
Purely random split test subjects into two groups, group A
gets the treatment, group B gets a placebo.
Often assumption of homogeneous group is made (same effect
for everybody), or, formally, a specific hypothesis needs to be
made at the start of the research about specific heterogeneity.
Medicine often has dangerous side effects for women (and
possibly children, or other minorities).
Time to market of new medicine also plays a role.
Maurits Kaptein (JADS): ”It is unethical to use randomized
controlled trials to personalize health-care”.
{patient, time, treatment, dose}
f
→ outcome
Edward
Python package for probabilistic modeling and inference
Build on top of Tensorflow
Bayesian neural networks
Non-Bayesian machine learning: point estimates of
coefficients and predictions
Bayesian: distributions of coefficients and predictions
Toy data set
A medicine that causes side
effects at a certain dose.
This maximum dose is
depending on gender and
age, and some individual
random noise.
However, the (test subjects)
population is mostly elderly
male.
Edward in action
Two-layer Bayesian neural
network.
Set priors uninformative but
at least somewhere near
results.
Posteriors after 1000
iterations.
Edward results
Biased for the lowest ages.
Doesn’t capture interaction
effect for lower ages.
Thompson sampling: when
searching max dose, treat
test subjects with doses
sampled from distribution.
Frequentist comparison
Frequentists show the effect
more clearly.
Assuming you actually have
the correct model
assumptions.
Posterior draws always
normal distributions, no
option to balance between
including or not including
interaction term.
Edward age as integer input
Trying to smooth by taking
age as single integer input
variable.
Bias variance trade-off.
Better at capturing
interaction effects, draws
look nice.
Doesn’t capture uncertainty
for lowest ages.
Frequentist vs. Bayesian neural network
Human hypothesis vs.
discovering with machine
learning.
Simple and specific input
variables (age and gender)
vs. many more possible
input variables (e.g. DNA or
smart sensor data)?
Problems with current
scientific incentives of
publication and going to
market in pharmaceutics.
Data volume: data from practice
The biggest problem is acquiring sufficient data to find
specific relationships, interactions and effects.
What if every treatment could be used as a data point?
Remove the strict boundary between research and application.
Thompson sampling in daily use:
Continuously update distributions with data from practice.
Sample optimal treatment from distributions.
Practical and ethical challenges
Practical challenges.
Would you want to be treated according to a randomly
sampled belief or the most likely belief?
Would you always want to be in an experiment?
However, current system is unfair because:
Unfair towards effects and side effects for minorities, because
you need to wait until somebody comes with a hypothesis and
start researching.
Longer time for a medicine to go to market, unfair for patients
that cannot get the treatment (yet).
Conclusion
Consider the cost of data acquisition as an essential topic for
any data scientist.
Strategic design of data collection, consider Thompson
sampling.
Edward is definitely worth discovering.
There is no such thing as a free lunch!

More Related Content

What's hot

Overview of recommender system
Overview of recommender systemOverview of recommender system
Overview of recommender systemStanley Wang
 
Markov Chain Monte Carlo explained
Markov Chain Monte Carlo explainedMarkov Chain Monte Carlo explained
Markov Chain Monte Carlo explaineddariodigiuni
 
Multi Task Learning for Recommendation Systems
Multi Task Learning for Recommendation SystemsMulti Task Learning for Recommendation Systems
Multi Task Learning for Recommendation SystemsVaibhav Singh
 
Recommender systems: Content-based and collaborative filtering
Recommender systems: Content-based and collaborative filteringRecommender systems: Content-based and collaborative filtering
Recommender systems: Content-based and collaborative filteringViet-Trung TRAN
 
A Multi-Armed Bandit Framework For Recommendations at Netflix
A Multi-Armed Bandit Framework For Recommendations at NetflixA Multi-Armed Bandit Framework For Recommendations at Netflix
A Multi-Armed Bandit Framework For Recommendations at NetflixJaya Kawale
 
Beyond Churn Prediction : An Introduction to uplift modeling
Beyond Churn Prediction : An Introduction to uplift modelingBeyond Churn Prediction : An Introduction to uplift modeling
Beyond Churn Prediction : An Introduction to uplift modelingPierre Gutierrez
 
Recommender system introduction
Recommender system   introductionRecommender system   introduction
Recommender system introductionLiang Xiang
 
Multi-armed bandit by Joni Turunen
Multi-armed bandit by Joni TurunenMulti-armed bandit by Joni Turunen
Multi-armed bandit by Joni TurunenFrosmo
 
Interactive Recommender Systems with Netflix and Spotify
Interactive Recommender Systems with Netflix and SpotifyInteractive Recommender Systems with Netflix and Spotify
Interactive Recommender Systems with Netflix and SpotifyChris Johnson
 
Multi-Agent Reinforcement Learning
Multi-Agent Reinforcement LearningMulti-Agent Reinforcement Learning
Multi-Agent Reinforcement LearningSeolhokim
 
RecSys 2020 A Human Perspective on Algorithmic Similarity Schendel 9-2020
RecSys 2020 A Human Perspective on Algorithmic Similarity Schendel 9-2020RecSys 2020 A Human Perspective on Algorithmic Similarity Schendel 9-2020
RecSys 2020 A Human Perspective on Algorithmic Similarity Schendel 9-2020Zachary Schendel
 
LinkedIn talk at Netflix ML Platform meetup Sep 2019
LinkedIn talk at Netflix ML Platform meetup Sep 2019LinkedIn talk at Netflix ML Platform meetup Sep 2019
LinkedIn talk at Netflix ML Platform meetup Sep 2019Faisal Siddiqi
 
Optimization in Deep Learning
Optimization in Deep LearningOptimization in Deep Learning
Optimization in Deep LearningYan Xu
 
Recommendation systems
Recommendation systemsRecommendation systems
Recommendation systemsSaurabhWani6
 
Reward Innovation for long-term member satisfaction
Reward Innovation for long-term member satisfactionReward Innovation for long-term member satisfaction
Reward Innovation for long-term member satisfactionJiangwei Pan
 
Why start using uplift models for more efficient marketing campaigns
Why start using uplift models for more efficient marketing campaignsWhy start using uplift models for more efficient marketing campaigns
Why start using uplift models for more efficient marketing campaignsData Con LA
 
Multi-armed Bandits
Multi-armed BanditsMulti-armed Bandits
Multi-armed BanditsDongmin Lee
 
Introduction to Uplift Modelling
Introduction to Uplift ModellingIntroduction to Uplift Modelling
Introduction to Uplift ModellingPierre Gutierrez
 
Understanding Bagging and Boosting
Understanding Bagging and BoostingUnderstanding Bagging and Boosting
Understanding Bagging and BoostingMohit Rajput
 

What's hot (20)

Overview of recommender system
Overview of recommender systemOverview of recommender system
Overview of recommender system
 
Markov Chain Monte Carlo explained
Markov Chain Monte Carlo explainedMarkov Chain Monte Carlo explained
Markov Chain Monte Carlo explained
 
Multi Task Learning for Recommendation Systems
Multi Task Learning for Recommendation SystemsMulti Task Learning for Recommendation Systems
Multi Task Learning for Recommendation Systems
 
Recommender systems: Content-based and collaborative filtering
Recommender systems: Content-based and collaborative filteringRecommender systems: Content-based and collaborative filtering
Recommender systems: Content-based and collaborative filtering
 
Tabu search
Tabu searchTabu search
Tabu search
 
A Multi-Armed Bandit Framework For Recommendations at Netflix
A Multi-Armed Bandit Framework For Recommendations at NetflixA Multi-Armed Bandit Framework For Recommendations at Netflix
A Multi-Armed Bandit Framework For Recommendations at Netflix
 
Beyond Churn Prediction : An Introduction to uplift modeling
Beyond Churn Prediction : An Introduction to uplift modelingBeyond Churn Prediction : An Introduction to uplift modeling
Beyond Churn Prediction : An Introduction to uplift modeling
 
Recommender system introduction
Recommender system   introductionRecommender system   introduction
Recommender system introduction
 
Multi-armed bandit by Joni Turunen
Multi-armed bandit by Joni TurunenMulti-armed bandit by Joni Turunen
Multi-armed bandit by Joni Turunen
 
Interactive Recommender Systems with Netflix and Spotify
Interactive Recommender Systems with Netflix and SpotifyInteractive Recommender Systems with Netflix and Spotify
Interactive Recommender Systems with Netflix and Spotify
 
Multi-Agent Reinforcement Learning
Multi-Agent Reinforcement LearningMulti-Agent Reinforcement Learning
Multi-Agent Reinforcement Learning
 
RecSys 2020 A Human Perspective on Algorithmic Similarity Schendel 9-2020
RecSys 2020 A Human Perspective on Algorithmic Similarity Schendel 9-2020RecSys 2020 A Human Perspective on Algorithmic Similarity Schendel 9-2020
RecSys 2020 A Human Perspective on Algorithmic Similarity Schendel 9-2020
 
LinkedIn talk at Netflix ML Platform meetup Sep 2019
LinkedIn talk at Netflix ML Platform meetup Sep 2019LinkedIn talk at Netflix ML Platform meetup Sep 2019
LinkedIn talk at Netflix ML Platform meetup Sep 2019
 
Optimization in Deep Learning
Optimization in Deep LearningOptimization in Deep Learning
Optimization in Deep Learning
 
Recommendation systems
Recommendation systemsRecommendation systems
Recommendation systems
 
Reward Innovation for long-term member satisfaction
Reward Innovation for long-term member satisfactionReward Innovation for long-term member satisfaction
Reward Innovation for long-term member satisfaction
 
Why start using uplift models for more efficient marketing campaigns
Why start using uplift models for more efficient marketing campaignsWhy start using uplift models for more efficient marketing campaigns
Why start using uplift models for more efficient marketing campaigns
 
Multi-armed Bandits
Multi-armed BanditsMulti-armed Bandits
Multi-armed Bandits
 
Introduction to Uplift Modelling
Introduction to Uplift ModellingIntroduction to Uplift Modelling
Introduction to Uplift Modelling
 
Understanding Bagging and Boosting
Understanding Bagging and BoostingUnderstanding Bagging and Boosting
Understanding Bagging and Boosting
 

Similar to Thompson Sampling for Machine Learning - Ruben Mak

Chapter 3 part1-Design of Experiments
Chapter 3 part1-Design of ExperimentsChapter 3 part1-Design of Experiments
Chapter 3 part1-Design of Experimentsnszakir
 
What's the Science in Data Science? - Skipper Seabold
What's the Science in Data Science? - Skipper SeaboldWhat's the Science in Data Science? - Skipper Seabold
What's the Science in Data Science? - Skipper SeaboldPyData
 
Essay On Juvenile Incarceration
Essay On Juvenile IncarcerationEssay On Juvenile Incarceration
Essay On Juvenile IncarcerationLissette Hartman
 
Stats Workshop2010
Stats Workshop2010Stats Workshop2010
Stats Workshop2010anesah
 
The ABC of Evidence-Base Medicine
The ABC of Evidence-Base MedicineThe ABC of Evidence-Base Medicine
The ABC of Evidence-Base MedicineDr Max Mongelli
 
Big Data: Learning from MIMIC- Celi
Big Data: Learning from MIMIC- CeliBig Data: Learning from MIMIC- Celi
Big Data: Learning from MIMIC- Celiintensivecaresociety
 
Causal inference for complex exposures: asking questions that matter, getting...
Causal inference for complex exposures: asking questions that matter, getting...Causal inference for complex exposures: asking questions that matter, getting...
Causal inference for complex exposures: asking questions that matter, getting...Ellie Murray
 
Hypothesis testing
Hypothesis testingHypothesis testing
Hypothesis testingpraveen3030
 
Asking Better Questions How Presentation Formats Influence Information Search
Asking Better Questions  How Presentation Formats Influence Information SearchAsking Better Questions  How Presentation Formats Influence Information Search
Asking Better Questions How Presentation Formats Influence Information SearchScott Bou
 
Introduction to statistics 2013
Introduction to statistics 2013Introduction to statistics 2013
Introduction to statistics 2013Mohammad Ihmeidan
 
演講-Meta analysis in medical research-張偉豪
演講-Meta analysis in medical research-張偉豪演講-Meta analysis in medical research-張偉豪
演講-Meta analysis in medical research-張偉豪Beckett Hsieh
 
How to read a paper
How to read a paperHow to read a paper
How to read a paperfaheta
 
DRUGS New agreement to tackle pharmaceutical pollution p.1
DRUGS New agreement to tackle pharmaceutical pollution p.1DRUGS New agreement to tackle pharmaceutical pollution p.1
DRUGS New agreement to tackle pharmaceutical pollution p.1AlyciaGold776
 
Methods to enhance the validity of precision guidelines emerging from big data
Methods to enhance the validity of precision guidelines emerging from big dataMethods to enhance the validity of precision guidelines emerging from big data
Methods to enhance the validity of precision guidelines emerging from big dataChirag Patel
 

Similar to Thompson Sampling for Machine Learning - Ruben Mak (20)

Chapter 3 part1-Design of Experiments
Chapter 3 part1-Design of ExperimentsChapter 3 part1-Design of Experiments
Chapter 3 part1-Design of Experiments
 
What's the Science in Data Science? - Skipper Seabold
What's the Science in Data Science? - Skipper SeaboldWhat's the Science in Data Science? - Skipper Seabold
What's the Science in Data Science? - Skipper Seabold
 
Essay On Juvenile Incarceration
Essay On Juvenile IncarcerationEssay On Juvenile Incarceration
Essay On Juvenile Incarceration
 
Stats Workshop2010
Stats Workshop2010Stats Workshop2010
Stats Workshop2010
 
Research by MAGIC
Research by MAGICResearch by MAGIC
Research by MAGIC
 
The ABC of Evidence-Base Medicine
The ABC of Evidence-Base MedicineThe ABC of Evidence-Base Medicine
The ABC of Evidence-Base Medicine
 
Big Data: Learning from MIMIC- Celi
Big Data: Learning from MIMIC- CeliBig Data: Learning from MIMIC- Celi
Big Data: Learning from MIMIC- Celi
 
Causal inference for complex exposures: asking questions that matter, getting...
Causal inference for complex exposures: asking questions that matter, getting...Causal inference for complex exposures: asking questions that matter, getting...
Causal inference for complex exposures: asking questions that matter, getting...
 
Hypothesis testing
Hypothesis testingHypothesis testing
Hypothesis testing
 
What is research
What is researchWhat is research
What is research
 
Asking Better Questions How Presentation Formats Influence Information Search
Asking Better Questions  How Presentation Formats Influence Information SearchAsking Better Questions  How Presentation Formats Influence Information Search
Asking Better Questions How Presentation Formats Influence Information Search
 
Introduction to statistics 2013
Introduction to statistics 2013Introduction to statistics 2013
Introduction to statistics 2013
 
3 cross sectional study
3 cross sectional study3 cross sectional study
3 cross sectional study
 
3 cross sectional study
3 cross sectional study3 cross sectional study
3 cross sectional study
 
演講-Meta analysis in medical research-張偉豪
演講-Meta analysis in medical research-張偉豪演講-Meta analysis in medical research-張偉豪
演講-Meta analysis in medical research-張偉豪
 
Patton1990
Patton1990Patton1990
Patton1990
 
How to read a paper
How to read a paperHow to read a paper
How to read a paper
 
DRUGS New agreement to tackle pharmaceutical pollution p.1
DRUGS New agreement to tackle pharmaceutical pollution p.1DRUGS New agreement to tackle pharmaceutical pollution p.1
DRUGS New agreement to tackle pharmaceutical pollution p.1
 
Methods to enhance the validity of precision guidelines emerging from big data
Methods to enhance the validity of precision guidelines emerging from big dataMethods to enhance the validity of precision guidelines emerging from big data
Methods to enhance the validity of precision guidelines emerging from big data
 
Hypothesis testing
Hypothesis testingHypothesis testing
Hypothesis testing
 

More from PyData

Michal Mucha: Build and Deploy an End-to-end Streaming NLP Insight System | P...
Michal Mucha: Build and Deploy an End-to-end Streaming NLP Insight System | P...Michal Mucha: Build and Deploy an End-to-end Streaming NLP Insight System | P...
Michal Mucha: Build and Deploy an End-to-end Streaming NLP Insight System | P...PyData
 
Unit testing data with marbles - Jane Stewart Adams, Leif Walsh
Unit testing data with marbles - Jane Stewart Adams, Leif WalshUnit testing data with marbles - Jane Stewart Adams, Leif Walsh
Unit testing data with marbles - Jane Stewart Adams, Leif WalshPyData
 
The TileDB Array Data Storage Manager - Stavros Papadopoulos, Jake Bolewski
The TileDB Array Data Storage Manager - Stavros Papadopoulos, Jake BolewskiThe TileDB Array Data Storage Manager - Stavros Papadopoulos, Jake Bolewski
The TileDB Array Data Storage Manager - Stavros Papadopoulos, Jake BolewskiPyData
 
Using Embeddings to Understand the Variance and Evolution of Data Science... ...
Using Embeddings to Understand the Variance and Evolution of Data Science... ...Using Embeddings to Understand the Variance and Evolution of Data Science... ...
Using Embeddings to Understand the Variance and Evolution of Data Science... ...PyData
 
Deploying Data Science for Distribution of The New York Times - Anne Bauer
Deploying Data Science for Distribution of The New York Times - Anne BauerDeploying Data Science for Distribution of The New York Times - Anne Bauer
Deploying Data Science for Distribution of The New York Times - Anne BauerPyData
 
Graph Analytics - From the Whiteboard to Your Toolbox - Sam Lerma
Graph Analytics - From the Whiteboard to Your Toolbox - Sam LermaGraph Analytics - From the Whiteboard to Your Toolbox - Sam Lerma
Graph Analytics - From the Whiteboard to Your Toolbox - Sam LermaPyData
 
Do Your Homework! Writing tests for Data Science and Stochastic Code - David ...
Do Your Homework! Writing tests for Data Science and Stochastic Code - David ...Do Your Homework! Writing tests for Data Science and Stochastic Code - David ...
Do Your Homework! Writing tests for Data Science and Stochastic Code - David ...PyData
 
RESTful Machine Learning with Flask and TensorFlow Serving - Carlo Mazzaferro
RESTful Machine Learning with Flask and TensorFlow Serving - Carlo MazzaferroRESTful Machine Learning with Flask and TensorFlow Serving - Carlo Mazzaferro
RESTful Machine Learning with Flask and TensorFlow Serving - Carlo MazzaferroPyData
 
Mining dockless bikeshare and dockless scootershare trip data - Stefanie Brod...
Mining dockless bikeshare and dockless scootershare trip data - Stefanie Brod...Mining dockless bikeshare and dockless scootershare trip data - Stefanie Brod...
Mining dockless bikeshare and dockless scootershare trip data - Stefanie Brod...PyData
 
Avoiding Bad Database Surprises: Simulation and Scalability - Steven Lott
Avoiding Bad Database Surprises: Simulation and Scalability - Steven LottAvoiding Bad Database Surprises: Simulation and Scalability - Steven Lott
Avoiding Bad Database Surprises: Simulation and Scalability - Steven LottPyData
 
Words in Space - Rebecca Bilbro
Words in Space - Rebecca BilbroWords in Space - Rebecca Bilbro
Words in Space - Rebecca BilbroPyData
 
End-to-End Machine learning pipelines for Python driven organizations - Nick ...
End-to-End Machine learning pipelines for Python driven organizations - Nick ...End-to-End Machine learning pipelines for Python driven organizations - Nick ...
End-to-End Machine learning pipelines for Python driven organizations - Nick ...PyData
 
Pydata beautiful soup - Monica Puerto
Pydata beautiful soup - Monica PuertoPydata beautiful soup - Monica Puerto
Pydata beautiful soup - Monica PuertoPyData
 
1D Convolutional Neural Networks for Time Series Modeling - Nathan Janos, Jef...
1D Convolutional Neural Networks for Time Series Modeling - Nathan Janos, Jef...1D Convolutional Neural Networks for Time Series Modeling - Nathan Janos, Jef...
1D Convolutional Neural Networks for Time Series Modeling - Nathan Janos, Jef...PyData
 
Extending Pandas with Custom Types - Will Ayd
Extending Pandas with Custom Types - Will AydExtending Pandas with Custom Types - Will Ayd
Extending Pandas with Custom Types - Will AydPyData
 
Measuring Model Fairness - Stephen Hoover
Measuring Model Fairness - Stephen HooverMeasuring Model Fairness - Stephen Hoover
Measuring Model Fairness - Stephen HooverPyData
 
Applying Statistical Modeling and Machine Learning to Perform Time-Series For...
Applying Statistical Modeling and Machine Learning to Perform Time-Series For...Applying Statistical Modeling and Machine Learning to Perform Time-Series For...
Applying Statistical Modeling and Machine Learning to Perform Time-Series For...PyData
 
Solving very simple substitution ciphers algorithmically - Stephen Enright-Ward
Solving very simple substitution ciphers algorithmically - Stephen Enright-WardSolving very simple substitution ciphers algorithmically - Stephen Enright-Ward
Solving very simple substitution ciphers algorithmically - Stephen Enright-WardPyData
 
The Face of Nanomaterials: Insightful Classification Using Deep Learning - An...
The Face of Nanomaterials: Insightful Classification Using Deep Learning - An...The Face of Nanomaterials: Insightful Classification Using Deep Learning - An...
The Face of Nanomaterials: Insightful Classification Using Deep Learning - An...PyData
 
Deprecating the state machine: building conversational AI with the Rasa stack...
Deprecating the state machine: building conversational AI with the Rasa stack...Deprecating the state machine: building conversational AI with the Rasa stack...
Deprecating the state machine: building conversational AI with the Rasa stack...PyData
 

More from PyData (20)

Michal Mucha: Build and Deploy an End-to-end Streaming NLP Insight System | P...
Michal Mucha: Build and Deploy an End-to-end Streaming NLP Insight System | P...Michal Mucha: Build and Deploy an End-to-end Streaming NLP Insight System | P...
Michal Mucha: Build and Deploy an End-to-end Streaming NLP Insight System | P...
 
Unit testing data with marbles - Jane Stewart Adams, Leif Walsh
Unit testing data with marbles - Jane Stewart Adams, Leif WalshUnit testing data with marbles - Jane Stewart Adams, Leif Walsh
Unit testing data with marbles - Jane Stewart Adams, Leif Walsh
 
The TileDB Array Data Storage Manager - Stavros Papadopoulos, Jake Bolewski
The TileDB Array Data Storage Manager - Stavros Papadopoulos, Jake BolewskiThe TileDB Array Data Storage Manager - Stavros Papadopoulos, Jake Bolewski
The TileDB Array Data Storage Manager - Stavros Papadopoulos, Jake Bolewski
 
Using Embeddings to Understand the Variance and Evolution of Data Science... ...
Using Embeddings to Understand the Variance and Evolution of Data Science... ...Using Embeddings to Understand the Variance and Evolution of Data Science... ...
Using Embeddings to Understand the Variance and Evolution of Data Science... ...
 
Deploying Data Science for Distribution of The New York Times - Anne Bauer
Deploying Data Science for Distribution of The New York Times - Anne BauerDeploying Data Science for Distribution of The New York Times - Anne Bauer
Deploying Data Science for Distribution of The New York Times - Anne Bauer
 
Graph Analytics - From the Whiteboard to Your Toolbox - Sam Lerma
Graph Analytics - From the Whiteboard to Your Toolbox - Sam LermaGraph Analytics - From the Whiteboard to Your Toolbox - Sam Lerma
Graph Analytics - From the Whiteboard to Your Toolbox - Sam Lerma
 
Do Your Homework! Writing tests for Data Science and Stochastic Code - David ...
Do Your Homework! Writing tests for Data Science and Stochastic Code - David ...Do Your Homework! Writing tests for Data Science and Stochastic Code - David ...
Do Your Homework! Writing tests for Data Science and Stochastic Code - David ...
 
RESTful Machine Learning with Flask and TensorFlow Serving - Carlo Mazzaferro
RESTful Machine Learning with Flask and TensorFlow Serving - Carlo MazzaferroRESTful Machine Learning with Flask and TensorFlow Serving - Carlo Mazzaferro
RESTful Machine Learning with Flask and TensorFlow Serving - Carlo Mazzaferro
 
Mining dockless bikeshare and dockless scootershare trip data - Stefanie Brod...
Mining dockless bikeshare and dockless scootershare trip data - Stefanie Brod...Mining dockless bikeshare and dockless scootershare trip data - Stefanie Brod...
Mining dockless bikeshare and dockless scootershare trip data - Stefanie Brod...
 
Avoiding Bad Database Surprises: Simulation and Scalability - Steven Lott
Avoiding Bad Database Surprises: Simulation and Scalability - Steven LottAvoiding Bad Database Surprises: Simulation and Scalability - Steven Lott
Avoiding Bad Database Surprises: Simulation and Scalability - Steven Lott
 
Words in Space - Rebecca Bilbro
Words in Space - Rebecca BilbroWords in Space - Rebecca Bilbro
Words in Space - Rebecca Bilbro
 
End-to-End Machine learning pipelines for Python driven organizations - Nick ...
End-to-End Machine learning pipelines for Python driven organizations - Nick ...End-to-End Machine learning pipelines for Python driven organizations - Nick ...
End-to-End Machine learning pipelines for Python driven organizations - Nick ...
 
Pydata beautiful soup - Monica Puerto
Pydata beautiful soup - Monica PuertoPydata beautiful soup - Monica Puerto
Pydata beautiful soup - Monica Puerto
 
1D Convolutional Neural Networks for Time Series Modeling - Nathan Janos, Jef...
1D Convolutional Neural Networks for Time Series Modeling - Nathan Janos, Jef...1D Convolutional Neural Networks for Time Series Modeling - Nathan Janos, Jef...
1D Convolutional Neural Networks for Time Series Modeling - Nathan Janos, Jef...
 
Extending Pandas with Custom Types - Will Ayd
Extending Pandas with Custom Types - Will AydExtending Pandas with Custom Types - Will Ayd
Extending Pandas with Custom Types - Will Ayd
 
Measuring Model Fairness - Stephen Hoover
Measuring Model Fairness - Stephen HooverMeasuring Model Fairness - Stephen Hoover
Measuring Model Fairness - Stephen Hoover
 
Applying Statistical Modeling and Machine Learning to Perform Time-Series For...
Applying Statistical Modeling and Machine Learning to Perform Time-Series For...Applying Statistical Modeling and Machine Learning to Perform Time-Series For...
Applying Statistical Modeling and Machine Learning to Perform Time-Series For...
 
Solving very simple substitution ciphers algorithmically - Stephen Enright-Ward
Solving very simple substitution ciphers algorithmically - Stephen Enright-WardSolving very simple substitution ciphers algorithmically - Stephen Enright-Ward
Solving very simple substitution ciphers algorithmically - Stephen Enright-Ward
 
The Face of Nanomaterials: Insightful Classification Using Deep Learning - An...
The Face of Nanomaterials: Insightful Classification Using Deep Learning - An...The Face of Nanomaterials: Insightful Classification Using Deep Learning - An...
The Face of Nanomaterials: Insightful Classification Using Deep Learning - An...
 
Deprecating the state machine: building conversational AI with the Rasa stack...
Deprecating the state machine: building conversational AI with the Rasa stack...Deprecating the state machine: building conversational AI with the Rasa stack...
Deprecating the state machine: building conversational AI with the Rasa stack...
 

Recently uploaded

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 

Recently uploaded (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

Thompson Sampling for Machine Learning - Ruben Mak

  • 1. Thompson Sampling for Machine Learning R.J. Mak Greenhouse Group PyData Amsterdam 2018 May, 26, 2018
  • 2. Introduction Group of online marketing agencies, part of GroupM Tech Hub Creative Hub Data Hub Data Science Team Data Technologist Team Data Insights Team Consumer Experience Marketing Team
  • 3. Multi-Armed Bandit Problem How to optimally insert coins in slot machines when reward distributions of each machine are unknown? Exploitation vs. exploration tradeoff
  • 4. Applications Any setting where data (observations) are costly. Pretty much any data science project, underemphasized. Deep learning: most focus on cases where data is (nearly) abundant. Classical examples: Finance Testing in online marketing (websites, ads) Budget allocation R&D Clinical trials
  • 6. Thompson Sampling: some history Formulated by Thompson in 1933. Allied scientists in World War II, proposed to drop the Multi-armed bandit problem over Germany so that German scientists could also waste their time on it. 1997 proof of convergence. Asymptotic convergence results for contextual bandits were published in 2011. 2012 proven to be optimal for the case of Bernoulli rewards (Lai and Robbins lower bound for the cumulative regret).
  • 7. Thompson Sampling Choosing the action that maximizes the expected reward with respect to a randomly drawn belief. Example of three slot machines, equal reward, probability of winning? Construct reward distribution. (Beta distribution). Sample from those distributions to choose the next slot machine.
  • 8. Thompson sampling using numpy 1 import numpy as np 2 3 plays = np.array([100, 20, 20]) 4 wins = np.array([32, 8, 5]) 5 num_samples = 1000000 6 7 p_A_sample = np.random.beta(wins[0], plays[0] - wins[0], num_samples) 8 p_B_sample = np.random.beta(wins[1], plays[1] - wins[1], num_samples) 9 p_C_sample = np.random.beta(wins[2], plays[2] - wins[2], num_samples) 10 11 mab_wins = np.array([0.0, 0.0, 0.0]) 12 13 for i in range(num_samples): 14 winner = np.argmax([p_A_sample[i], p_B_sample[i], p_C_sample[i]]) 15 mab_wins[winner] += 1 16 17 mab_wins = mab_wins / num_samples 18 19 print(mab_wins)
  • 9. Prediction probabilities vs. prediction distributions Prediction probabilities and prediction distributions both say something about uncertainty, what’s the difference? In the example of object detection, the probabilities are point estimates of how likely the thing in the picture is a certain object, for that specific picture. It captures the uncertainty from the input image. However, it does not capture the uncertainty from the data used to train the model. This is what we want to capture with a prediction distribution.
  • 10. Prediction probabilities vs. prediction distributions
  • 11. Traditional (frequentist) clinical trial Purely random split test subjects into two groups, group A gets the treatment, group B gets a placebo. Often assumption of homogeneous group is made (same effect for everybody), or, formally, a specific hypothesis needs to be made at the start of the research about specific heterogeneity. Medicine often has dangerous side effects for women (and possibly children, or other minorities). Time to market of new medicine also plays a role. Maurits Kaptein (JADS): ”It is unethical to use randomized controlled trials to personalize health-care”. {patient, time, treatment, dose} f → outcome
  • 12. Edward Python package for probabilistic modeling and inference Build on top of Tensorflow Bayesian neural networks Non-Bayesian machine learning: point estimates of coefficients and predictions Bayesian: distributions of coefficients and predictions
  • 13. Toy data set A medicine that causes side effects at a certain dose. This maximum dose is depending on gender and age, and some individual random noise. However, the (test subjects) population is mostly elderly male.
  • 14. Edward in action Two-layer Bayesian neural network. Set priors uninformative but at least somewhere near results. Posteriors after 1000 iterations.
  • 15. Edward results Biased for the lowest ages. Doesn’t capture interaction effect for lower ages. Thompson sampling: when searching max dose, treat test subjects with doses sampled from distribution.
  • 16. Frequentist comparison Frequentists show the effect more clearly. Assuming you actually have the correct model assumptions. Posterior draws always normal distributions, no option to balance between including or not including interaction term.
  • 17. Edward age as integer input Trying to smooth by taking age as single integer input variable. Bias variance trade-off. Better at capturing interaction effects, draws look nice. Doesn’t capture uncertainty for lowest ages.
  • 18. Frequentist vs. Bayesian neural network Human hypothesis vs. discovering with machine learning. Simple and specific input variables (age and gender) vs. many more possible input variables (e.g. DNA or smart sensor data)? Problems with current scientific incentives of publication and going to market in pharmaceutics.
  • 19. Data volume: data from practice The biggest problem is acquiring sufficient data to find specific relationships, interactions and effects. What if every treatment could be used as a data point? Remove the strict boundary between research and application. Thompson sampling in daily use: Continuously update distributions with data from practice. Sample optimal treatment from distributions.
  • 20. Practical and ethical challenges Practical challenges. Would you want to be treated according to a randomly sampled belief or the most likely belief? Would you always want to be in an experiment? However, current system is unfair because: Unfair towards effects and side effects for minorities, because you need to wait until somebody comes with a hypothesis and start researching. Longer time for a medicine to go to market, unfair for patients that cannot get the treatment (yet).
  • 21. Conclusion Consider the cost of data acquisition as an essential topic for any data scientist. Strategic design of data collection, consider Thompson sampling. Edward is definitely worth discovering. There is no such thing as a free lunch!