SlideShare a Scribd company logo
1 of 21
Intro to Probabilistic
Programming –
PyMC3 & Edward
HARIHARAN CHANDRASEKARAN
Frequentists vs Bayesian
 In a debugging problem, frequentist function with argument ‘My code
passed all X tests, is my code bug free?’ would return a YES
 Bayesian function with argument ‘Often my code has bugs. My code
passed all X tests; is my code bug free?’ would return Yes with prob 0.8
and NO with prob 0.2
 Additional argument in Bayesian – Often my code has bugs.
 This is called prior
 Prior is our belief about the situation
Why probabilistic
 Number of instances as evidence – N
 As N -> ∞ Bayesian (often) aligns with frequentist results
 For small N, inference is unstable. Frequentist estimates have more
variance and larger confidence intervals. Bayesian inference excels
 For large N, quote Andrew Gelman – N can never be large enough
 Bayes Formula fundamental
MCMC
MCMC
INPUT PROCESS OUTPUT
MCMC
INPUT
PROCESS
OUTPUT
data
model
sampler
prior
Metropolis Rule
High P region
P0, θ0
P1, θ1
• If P1 > P0 accept the
jump
• If P1 < P0 we make the
jump with a probability
P1/P0
• Successful jumps form
a chain called Markov
Chain
• Algorithm is endless –
Orbit true solution but
never stop at it
• How to make jumps?
θ1 = θ0 + Ń(0, Δθ)
Metropolis Hastings – Jump with probability min(q, 1) where
q = P(θ1)/J(θ1 | θ0)
----------------------------------
P(θ0)/J(θ0 | θ1)
Gibbs Sampling
Assuming θ1, θ2, θ3 are parameters
of posterior
• We need to know this
conditional probability
distributions
• Gibbs sampling thus is
a special case of
metropolis rule
• Successful jumps form
a chain called Markov
Chain
• Algorithm is endless –
Orbit true solution but
never stop at it
• Practically not always
feasible
Mathematically proven that this algorithm
asymptotically converges to the solution
• Define P(θ1, θ2, θ3)
• Sample θ0
1, θ0
2, θ0
3 from prior
• For t in 1:T
• Θt
1 ~ P(θ1 | θt-1
2, θt-1
3)
• Θt
2 ~ P(θ2 | θt
1, θt-1
3)
• Θt
3 ~ P(θ3 | θt
1, θt
2)
Variational Inference
Information Theory
• Information = - log(p(x))
• Entropy = - ∑ p(x)log(p(x))
• Differential Entropy = - ∫ p(x)log(p(x))dx
KL Divergence
• Measures distance between 2 probability
distributions
• KL(p||q) = [- ∑ p(x)log(q(x))] - [- ∑
p(x)log(p(x))] = - ∑ p(x)log(q(x)/p(x))
• KL ≥ 0
• KL(p||q) <> KL(q||p)
Use KL Divergence
• We have P(x, z) but we want to know P(z|x) -
> P’
• So we create q(z)
• KL(p’||q) + L = log(p(x))
• L is a function of p(x, z) and q(z)
• Minimizing KL same as maximizing L
• After some neat math, we get q to be an
exponential distribution -> Neat and
convenient
VI vs MCMC
• VI is deterministic and is an approximation
• MCMC is a sampling solution and is an
approximation
• Generally, MCMC solutions considered to be
more accurate
Coin Toss
 >>> x_train
array([1, 1, 0, 1, 0, 1, 1,……., 0,
1], dtype=int32)
 >>> sum(x_train == 0)
40
 >>> sum(x_train == 1)
60
You toss a coin
100 times and
see 60 heads. Is it
a fair coin?
How do we build a model in
Probabilistic models?
 Posit a generative model
 Start with a simple story about how the data is generated
 What probability distribution could explain the seeing coin tosses like the ones
observed? – Forward Thinking
 Infer Model Parameters
 Infer specifics about story based on observations
 Given model and data, how likely is it that the coin has a particular fairness? –
Backward Thinking
 Criticize the model
 Can simple story explain the observations? Can we improve the story?
Model Building
 Process of stating our beliefs about how the data could have been
generated
 Models are simplified descriptions of the data
 Models can be declared as abstract mathematical descriptions or as code
 Models allow for simulation of data
Generative Model for a coin toss
 Model expressed in terms of probability distribution
 P(params, data) = p(params) x p(data | params)
 params: fairness of the coin
 data: coin tosses
 p(params): prior probability of a certain fairness
 p(data|params): conditional probability that the data is observed given that coin
has a certain fairness
 p(params, data): Joint Probability that botht the data is observed and coin has a
certain fairness
Generative
Model for
coin toss  >>> pheads =
Uniform(low=0., high=1.)
 >>> c =
Bernoulli(probs=pheads,
sample_shape=100)
Our story in Edward
Uniform: Prior
Bernoulli: conditional
Real Life Scenarios
 We take an open dataset on Climate of Major cities across the world from
Kaggle. Click here for dataset
 Using Bayesian Inference, we try to answer the following questions:
 Are the major cities having temperature variability higher than a threshold in
the weather pattern?
 What is the probability that any randomly chosen year has high temperature
increase greater than a threshold?
 PPL framework – PyMC3
 Solution available in a Jupyter Notebook – Click here for Notebook
 Notebook will continue to be edited
Real Life Scenarios (Contd.)
 We take an open dataset on district-wise education metrics in India from
Kaggle. Click here for dataset
 Using Bayesian ML, we try to do Regression and Classification on above
problem
 PPL framework – PyMC3 and Edward
 Solution available in Jupyter Notebooks – Click here and here for
Notebooks
 Notebooks will continue to be edited
Causal evidence
Evidential Reasoning
Intercausal reasoning
Probabilistic – Pros /
Criticism
 Can work with small / medium
data
 Research on black box
interpretability
 Nuanced risk functions – Good
inference and decision theory, not
just prediction
• No Free Lunch
• Bad Throughput
Skill sets – Statistical Analysis, ML/DL, Advanced
Probability and Statistics
Closing tips for
theoretical and
practical start points
 Best is to build models from scratch
 Or use weights of existing model as
priors and continue
 Hypothesis testing in probabilistic way
 Outlier analysis
 Comparison of a NN traditional vs
probabilistic
 PyMC3 and Edward
 Stan getting popular
 Edward 2.0 will be compatible with latest
TF
 Pymc4 will be built on TF
• Learn MCMC
• MCMC algorithms like:
• Gibbs Sampling
• Metropolis Hastings
• Variational Inference
• How to create priors
• Model evaluation
Thank You!
 Questions / Comments

More Related Content

What's hot

Artificial Intelligence Notes Unit 3
Artificial Intelligence Notes Unit 3Artificial Intelligence Notes Unit 3
Artificial Intelligence Notes Unit 3DigiGurukul
 
Composing graphical models with neural networks for structured representatio...
Composing graphical models with  neural networks for structured representatio...Composing graphical models with  neural networks for structured representatio...
Composing graphical models with neural networks for structured representatio...Jeongmin Cha
 
Computational learning theory
Computational learning theoryComputational learning theory
Computational learning theoryswapnac12
 
Natural Language Processing: L03 maths fornlp
Natural Language Processing: L03 maths fornlpNatural Language Processing: L03 maths fornlp
Natural Language Processing: L03 maths fornlpananth
 
coppin chapter 10e.ppt
coppin chapter 10e.pptcoppin chapter 10e.ppt
coppin chapter 10e.pptbutest
 
Bayesian Networks - A Brief Introduction
Bayesian Networks - A Brief IntroductionBayesian Networks - A Brief Introduction
Bayesian Networks - A Brief IntroductionAdnan Masood
 
Machine Learning
Machine LearningMachine Learning
Machine Learningbutest
 
Machine Learning 1 - Introduction
Machine Learning 1 - IntroductionMachine Learning 1 - Introduction
Machine Learning 1 - Introductionbutest
 
original
originaloriginal
originalbutest
 
Download presentation source
Download presentation sourceDownload presentation source
Download presentation sourcebutest
 
Element distinctness lower bounds
Element distinctness lower boundsElement distinctness lower bounds
Element distinctness lower boundsRajendran
 
Naive Bayes Classifier
Naive Bayes ClassifierNaive Bayes Classifier
Naive Bayes ClassifierArunabha Saha
 
Inductive bias
Inductive biasInductive bias
Inductive biasswapnac12
 

What's hot (20)

Artificial Intelligence Notes Unit 3
Artificial Intelligence Notes Unit 3Artificial Intelligence Notes Unit 3
Artificial Intelligence Notes Unit 3
 
Composing graphical models with neural networks for structured representatio...
Composing graphical models with  neural networks for structured representatio...Composing graphical models with  neural networks for structured representatio...
Composing graphical models with neural networks for structured representatio...
 
Computational learning theory
Computational learning theoryComputational learning theory
Computational learning theory
 
Reasoning in AI
Reasoning in AIReasoning in AI
Reasoning in AI
 
Natural Language Processing: L03 maths fornlp
Natural Language Processing: L03 maths fornlpNatural Language Processing: L03 maths fornlp
Natural Language Processing: L03 maths fornlp
 
coppin chapter 10e.ppt
coppin chapter 10e.pptcoppin chapter 10e.ppt
coppin chapter 10e.ppt
 
Bayesian Networks - A Brief Introduction
Bayesian Networks - A Brief IntroductionBayesian Networks - A Brief Introduction
Bayesian Networks - A Brief Introduction
 
Machine Learning
Machine LearningMachine Learning
Machine Learning
 
Machine Learning 1 - Introduction
Machine Learning 1 - IntroductionMachine Learning 1 - Introduction
Machine Learning 1 - Introduction
 
DISMATH_Part1
DISMATH_Part1DISMATH_Part1
DISMATH_Part1
 
Uncertainty
UncertaintyUncertainty
Uncertainty
 
original
originaloriginal
original
 
Download presentation source
Download presentation sourceDownload presentation source
Download presentation source
 
Dismath part2 2013
Dismath part2 2013Dismath part2 2013
Dismath part2 2013
 
DISMATH_Part2
DISMATH_Part2DISMATH_Part2
DISMATH_Part2
 
Element distinctness lower bounds
Element distinctness lower boundsElement distinctness lower bounds
Element distinctness lower bounds
 
Naive Bayes Classifier
Naive Bayes ClassifierNaive Bayes Classifier
Naive Bayes Classifier
 
Lower bound
Lower boundLower bound
Lower bound
 
Module 4 part_1
Module 4 part_1Module 4 part_1
Module 4 part_1
 
Inductive bias
Inductive biasInductive bias
Inductive bias
 

Similar to Into to prob_prog_hari

Intro to Model Selection
Intro to Model SelectionIntro to Model Selection
Intro to Model Selectionchenhm
 
Bayesian Neural Networks
Bayesian Neural NetworksBayesian Neural Networks
Bayesian Neural NetworksNatan Katz
 
Data mining maximumlikelihood
Data mining maximumlikelihoodData mining maximumlikelihood
Data mining maximumlikelihoodHarry Potter
 
Data mining maximumlikelihood
Data mining maximumlikelihoodData mining maximumlikelihood
Data mining maximumlikelihoodJames Wong
 
Data mining maximumlikelihood
Data mining maximumlikelihoodData mining maximumlikelihood
Data mining maximumlikelihoodHoang Nguyen
 
Data mining maximumlikelihood
Data mining maximumlikelihoodData mining maximumlikelihood
Data mining maximumlikelihoodYoung Alista
 
Data miningmaximumlikelihood
Data miningmaximumlikelihoodData miningmaximumlikelihood
Data miningmaximumlikelihoodFraboni Ec
 
Data mining maximumlikelihood
Data mining maximumlikelihoodData mining maximumlikelihood
Data mining maximumlikelihoodTony Nguyen
 
Data mining maximumlikelihood
Data mining maximumlikelihoodData mining maximumlikelihood
Data mining maximumlikelihoodLuis Goldster
 
. An introduction to machine learning and probabilistic ...
. An introduction to machine learning and probabilistic .... An introduction to machine learning and probabilistic ...
. An introduction to machine learning and probabilistic ...butest
 
Anomaly detection Full Article
Anomaly detection Full ArticleAnomaly detection Full Article
Anomaly detection Full ArticleMenglinLiu1
 
Introduction to Bayesian Analysis in Python
Introduction to Bayesian Analysis in PythonIntroduction to Bayesian Analysis in Python
Introduction to Bayesian Analysis in PythonPeadar Coyle
 
Variational Inference in Python
Variational Inference in PythonVariational Inference in Python
Variational Inference in PythonPeadar Coyle
 
Unbiased Bayes for Big Data
Unbiased Bayes for Big DataUnbiased Bayes for Big Data
Unbiased Bayes for Big DataChristian Robert
 
Introduction to Maximum Likelihood Estimator
Introduction to Maximum Likelihood EstimatorIntroduction to Maximum Likelihood Estimator
Introduction to Maximum Likelihood EstimatorAmir Al-Ansary
 
Firefly exact MCMC for Big Data
Firefly exact MCMC for Big DataFirefly exact MCMC for Big Data
Firefly exact MCMC for Big DataGianvito Siciliano
 
Intro to Feature Selection
Intro to Feature SelectionIntro to Feature Selection
Intro to Feature Selectionchenhm
 

Similar to Into to prob_prog_hari (20)

Intro to Model Selection
Intro to Model SelectionIntro to Model Selection
Intro to Model Selection
 
Bayesian Neural Networks
Bayesian Neural NetworksBayesian Neural Networks
Bayesian Neural Networks
 
Data mining maximumlikelihood
Data mining maximumlikelihoodData mining maximumlikelihood
Data mining maximumlikelihood
 
Data mining maximumlikelihood
Data mining maximumlikelihoodData mining maximumlikelihood
Data mining maximumlikelihood
 
Data mining maximumlikelihood
Data mining maximumlikelihoodData mining maximumlikelihood
Data mining maximumlikelihood
 
Data mining maximumlikelihood
Data mining maximumlikelihoodData mining maximumlikelihood
Data mining maximumlikelihood
 
Data miningmaximumlikelihood
Data miningmaximumlikelihoodData miningmaximumlikelihood
Data miningmaximumlikelihood
 
Data mining maximumlikelihood
Data mining maximumlikelihoodData mining maximumlikelihood
Data mining maximumlikelihood
 
Data mining maximumlikelihood
Data mining maximumlikelihoodData mining maximumlikelihood
Data mining maximumlikelihood
 
. An introduction to machine learning and probabilistic ...
. An introduction to machine learning and probabilistic .... An introduction to machine learning and probabilistic ...
. An introduction to machine learning and probabilistic ...
 
Anomaly detection Full Article
Anomaly detection Full ArticleAnomaly detection Full Article
Anomaly detection Full Article
 
Introduction to Bayesian Analysis in Python
Introduction to Bayesian Analysis in PythonIntroduction to Bayesian Analysis in Python
Introduction to Bayesian Analysis in Python
 
Machine learning mathematicals.pdf
Machine learning mathematicals.pdfMachine learning mathematicals.pdf
Machine learning mathematicals.pdf
 
MLE.pdf
MLE.pdfMLE.pdf
MLE.pdf
 
Variational Inference in Python
Variational Inference in PythonVariational Inference in Python
Variational Inference in Python
 
Unbiased Bayes for Big Data
Unbiased Bayes for Big DataUnbiased Bayes for Big Data
Unbiased Bayes for Big Data
 
Introduction to Maximum Likelihood Estimator
Introduction to Maximum Likelihood EstimatorIntroduction to Maximum Likelihood Estimator
Introduction to Maximum Likelihood Estimator
 
Firefly exact MCMC for Big Data
Firefly exact MCMC for Big DataFirefly exact MCMC for Big Data
Firefly exact MCMC for Big Data
 
Intro to Feature Selection
Intro to Feature SelectionIntro to Feature Selection
Intro to Feature Selection
 
Workshop on Bayesian Workflows with CmdStanPy by Mitzi Morris
Workshop on Bayesian Workflows with CmdStanPy by Mitzi MorrisWorkshop on Bayesian Workflows with CmdStanPy by Mitzi Morris
Workshop on Bayesian Workflows with CmdStanPy by Mitzi Morris
 

Recently uploaded

Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...HyderabadDolls
 
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...gajnagarg
 
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...gajnagarg
 
👉 Bhilai Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Girl Ser...
👉 Bhilai Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Girl Ser...👉 Bhilai Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Girl Ser...
👉 Bhilai Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Girl Ser...vershagrag
 
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabiaahmedjiabur940
 
Introduction to Statistics Presentation.pptx
Introduction to Statistics Presentation.pptxIntroduction to Statistics Presentation.pptx
Introduction to Statistics Presentation.pptxAniqa Zai
 
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...HyderabadDolls
 
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...SOFTTECHHUB
 
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...Elaine Werffeli
 
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...ThinkInnovation
 
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...HyderabadDolls
 
Statistics notes ,it includes mean to index numbers
Statistics notes ,it includes mean to index numbersStatistics notes ,it includes mean to index numbers
Statistics notes ,it includes mean to index numberssuginr1
 
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...HyderabadDolls
 
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...nirzagarg
 
💞 Safe And Secure Call Girls Agra Call Girls Service Just Call 🍑👄6378878445 🍑...
💞 Safe And Secure Call Girls Agra Call Girls Service Just Call 🍑👄6378878445 🍑...💞 Safe And Secure Call Girls Agra Call Girls Service Just Call 🍑👄6378878445 🍑...
💞 Safe And Secure Call Girls Agra Call Girls Service Just Call 🍑👄6378878445 🍑...vershagrag
 
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...HyderabadDolls
 
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...nirzagarg
 
Belur $ Female Escorts Service in Kolkata (Adult Only) 8005736733 Escort Serv...
Belur $ Female Escorts Service in Kolkata (Adult Only) 8005736733 Escort Serv...Belur $ Female Escorts Service in Kolkata (Adult Only) 8005736733 Escort Serv...
Belur $ Female Escorts Service in Kolkata (Adult Only) 8005736733 Escort Serv...HyderabadDolls
 

Recently uploaded (20)

Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
 
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
 
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
 
👉 Bhilai Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Girl Ser...
👉 Bhilai Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Girl Ser...👉 Bhilai Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Girl Ser...
👉 Bhilai Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Girl Ser...
 
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
 
Introduction to Statistics Presentation.pptx
Introduction to Statistics Presentation.pptxIntroduction to Statistics Presentation.pptx
Introduction to Statistics Presentation.pptx
 
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
 
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
 
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
 
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
 
Abortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get CytotecAbortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get Cytotec
 
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
 
Call Girls in G.T.B. Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in G.T.B. Nagar  (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in G.T.B. Nagar  (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in G.T.B. Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Statistics notes ,it includes mean to index numbers
Statistics notes ,it includes mean to index numbersStatistics notes ,it includes mean to index numbers
Statistics notes ,it includes mean to index numbers
 
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
 
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
 
💞 Safe And Secure Call Girls Agra Call Girls Service Just Call 🍑👄6378878445 🍑...
💞 Safe And Secure Call Girls Agra Call Girls Service Just Call 🍑👄6378878445 🍑...💞 Safe And Secure Call Girls Agra Call Girls Service Just Call 🍑👄6378878445 🍑...
💞 Safe And Secure Call Girls Agra Call Girls Service Just Call 🍑👄6378878445 🍑...
 
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
 
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
 
Belur $ Female Escorts Service in Kolkata (Adult Only) 8005736733 Escort Serv...
Belur $ Female Escorts Service in Kolkata (Adult Only) 8005736733 Escort Serv...Belur $ Female Escorts Service in Kolkata (Adult Only) 8005736733 Escort Serv...
Belur $ Female Escorts Service in Kolkata (Adult Only) 8005736733 Escort Serv...
 

Into to prob_prog_hari

  • 1. Intro to Probabilistic Programming – PyMC3 & Edward HARIHARAN CHANDRASEKARAN
  • 2. Frequentists vs Bayesian  In a debugging problem, frequentist function with argument ‘My code passed all X tests, is my code bug free?’ would return a YES  Bayesian function with argument ‘Often my code has bugs. My code passed all X tests; is my code bug free?’ would return Yes with prob 0.8 and NO with prob 0.2  Additional argument in Bayesian – Often my code has bugs.  This is called prior  Prior is our belief about the situation
  • 3. Why probabilistic  Number of instances as evidence – N  As N -> ∞ Bayesian (often) aligns with frequentist results  For small N, inference is unstable. Frequentist estimates have more variance and larger confidence intervals. Bayesian inference excels  For large N, quote Andrew Gelman – N can never be large enough  Bayes Formula fundamental
  • 6. Metropolis Rule High P region P0, θ0 P1, θ1 • If P1 > P0 accept the jump • If P1 < P0 we make the jump with a probability P1/P0 • Successful jumps form a chain called Markov Chain • Algorithm is endless – Orbit true solution but never stop at it • How to make jumps? θ1 = θ0 + Ń(0, Δθ) Metropolis Hastings – Jump with probability min(q, 1) where q = P(θ1)/J(θ1 | θ0) ---------------------------------- P(θ0)/J(θ0 | θ1)
  • 7. Gibbs Sampling Assuming θ1, θ2, θ3 are parameters of posterior • We need to know this conditional probability distributions • Gibbs sampling thus is a special case of metropolis rule • Successful jumps form a chain called Markov Chain • Algorithm is endless – Orbit true solution but never stop at it • Practically not always feasible Mathematically proven that this algorithm asymptotically converges to the solution • Define P(θ1, θ2, θ3) • Sample θ0 1, θ0 2, θ0 3 from prior • For t in 1:T • Θt 1 ~ P(θ1 | θt-1 2, θt-1 3) • Θt 2 ~ P(θ2 | θt 1, θt-1 3) • Θt 3 ~ P(θ3 | θt 1, θt 2)
  • 8. Variational Inference Information Theory • Information = - log(p(x)) • Entropy = - ∑ p(x)log(p(x)) • Differential Entropy = - ∫ p(x)log(p(x))dx KL Divergence • Measures distance between 2 probability distributions • KL(p||q) = [- ∑ p(x)log(q(x))] - [- ∑ p(x)log(p(x))] = - ∑ p(x)log(q(x)/p(x)) • KL ≥ 0 • KL(p||q) <> KL(q||p) Use KL Divergence • We have P(x, z) but we want to know P(z|x) - > P’ • So we create q(z) • KL(p’||q) + L = log(p(x)) • L is a function of p(x, z) and q(z) • Minimizing KL same as maximizing L • After some neat math, we get q to be an exponential distribution -> Neat and convenient VI vs MCMC • VI is deterministic and is an approximation • MCMC is a sampling solution and is an approximation • Generally, MCMC solutions considered to be more accurate
  • 9. Coin Toss  >>> x_train array([1, 1, 0, 1, 0, 1, 1,……., 0, 1], dtype=int32)  >>> sum(x_train == 0) 40  >>> sum(x_train == 1) 60 You toss a coin 100 times and see 60 heads. Is it a fair coin?
  • 10. How do we build a model in Probabilistic models?  Posit a generative model  Start with a simple story about how the data is generated  What probability distribution could explain the seeing coin tosses like the ones observed? – Forward Thinking  Infer Model Parameters  Infer specifics about story based on observations  Given model and data, how likely is it that the coin has a particular fairness? – Backward Thinking  Criticize the model  Can simple story explain the observations? Can we improve the story?
  • 11. Model Building  Process of stating our beliefs about how the data could have been generated  Models are simplified descriptions of the data  Models can be declared as abstract mathematical descriptions or as code  Models allow for simulation of data
  • 12. Generative Model for a coin toss  Model expressed in terms of probability distribution  P(params, data) = p(params) x p(data | params)  params: fairness of the coin  data: coin tosses  p(params): prior probability of a certain fairness  p(data|params): conditional probability that the data is observed given that coin has a certain fairness  p(params, data): Joint Probability that botht the data is observed and coin has a certain fairness
  • 13. Generative Model for coin toss  >>> pheads = Uniform(low=0., high=1.)  >>> c = Bernoulli(probs=pheads, sample_shape=100) Our story in Edward Uniform: Prior Bernoulli: conditional
  • 14. Real Life Scenarios  We take an open dataset on Climate of Major cities across the world from Kaggle. Click here for dataset  Using Bayesian Inference, we try to answer the following questions:  Are the major cities having temperature variability higher than a threshold in the weather pattern?  What is the probability that any randomly chosen year has high temperature increase greater than a threshold?  PPL framework – PyMC3  Solution available in a Jupyter Notebook – Click here for Notebook  Notebook will continue to be edited
  • 15. Real Life Scenarios (Contd.)  We take an open dataset on district-wise education metrics in India from Kaggle. Click here for dataset  Using Bayesian ML, we try to do Regression and Classification on above problem  PPL framework – PyMC3 and Edward  Solution available in Jupyter Notebooks – Click here and here for Notebooks  Notebooks will continue to be edited
  • 19. Probabilistic – Pros / Criticism  Can work with small / medium data  Research on black box interpretability  Nuanced risk functions – Good inference and decision theory, not just prediction • No Free Lunch • Bad Throughput Skill sets – Statistical Analysis, ML/DL, Advanced Probability and Statistics
  • 20. Closing tips for theoretical and practical start points  Best is to build models from scratch  Or use weights of existing model as priors and continue  Hypothesis testing in probabilistic way  Outlier analysis  Comparison of a NN traditional vs probabilistic  PyMC3 and Edward  Stan getting popular  Edward 2.0 will be compatible with latest TF  Pymc4 will be built on TF • Learn MCMC • MCMC algorithms like: • Gibbs Sampling • Metropolis Hastings • Variational Inference • How to create priors • Model evaluation