SlideShare ist ein Scribd-Unternehmen logo
1 von 71
Downloaden Sie, um offline zu lesen
PyMC3 – Bayesian Statistical Modelling in Python
Max Kochurov
22 June, 2019
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 1 / 29
About me
Max Kochurov tg,slack:@ferres / github:ferrine
Geoopt
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 2 / 29
Bayesian Statistics
Figure: Updating prior p(λ)
p(λ | D) =
p(D | λ)p(λ)
p(D)
• p(λ) – Prior, base knowledge
• p(D | λ) – Likelihood, new information
• p(λ | D) – Posterior, updated knowledge
• p(D) – Evidence, surprise in data
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 3 / 29
Bayesian Statistics
p(λ | D) =
p(D | λ)p(λ)
p(D)
• p(λ) – Prior, base knowledge
• p(D | λ) – Likelihood, new information
• p(λ | D) – Posterior, updated knowledge
• p(D) – Evidence, surprise in data
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 3 / 29
Bayesian Statistics
Compared to Frequentist
• Elegant way to put assumptions in the
model
• Can work with few Data!
• No need for p-values,
all you need is p(λ | D)
• . . .
p(λ | D) =
p(D | λ)p(λ)
p(D)
• p(λ) – Prior, base knowledge
• p(D | λ) – Likelihood, new information
• p(λ | D) – Posterior, updated knowledge
• p(D) – Evidence, surprise in data
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 3 / 29
Where do people use Bayesian inference?
• Finance (Quantopian): estimating the performance of trading algorithms
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 4 / 29
Where do people use Bayesian inference?
• Finance (Quantopian): estimating the performance of trading algorithms
• Music Streaming (Sounds): A/B testing, churn prediction, lifetime value, defining user
session
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 4 / 29
Where do people use Bayesian inference?
• Finance (Quantopian): estimating the performance of trading algorithms
• Music Streaming (Sounds): A/B testing, churn prediction, lifetime value, defining user
session
• E-Commerce (Salesforce): A/B tests, combining disparate sources of information,
hierarchical models
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 4 / 29
Where do people use Bayesian inference?
• Finance (Quantopian): estimating the performance of trading algorithms
• Music Streaming (Sounds): A/B testing, churn prediction, lifetime value, defining user
session
• E-Commerce (Salesforce): A/B tests, combining disparate sources of information,
hierarchical models
• Astronomy: estimating orbits of space objects, getting an image of a black hole
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 4 / 29
Where do people use Bayesian inference?
• Finance (Quantopian): estimating the performance of trading algorithms
• Music Streaming (Sounds): A/B testing, churn prediction, lifetime value, defining user
session
• E-Commerce (Salesforce): A/B tests, combining disparate sources of information,
hierarchical models
• Astronomy: estimating orbits of space objects, getting an image of a black hole
• Life science: epidemic analysis
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 4 / 29
Where do people use Bayesian inference?
• Finance (Quantopian): estimating the performance of trading algorithms
• Music Streaming (Sounds): A/B testing, churn prediction, lifetime value, defining user
session
• E-Commerce (Salesforce): A/B tests, combining disparate sources of information,
hierarchical models
• Astronomy: estimating orbits of space objects, getting an image of a black hole
• Life science: epidemic analysis
• Medicine: calculating effect sizes for drugs
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 4 / 29
Where do people use Bayesian inference?
• Finance (Quantopian): estimating the performance of trading algorithms
• Music Streaming (Sounds): A/B testing, churn prediction, lifetime value, defining user
session
• E-Commerce (Salesforce): A/B tests, combining disparate sources of information,
hierarchical models
• Astronomy: estimating orbits of space objects, getting an image of a black hole
• Life science: epidemic analysis
• Medicine: calculating effect sizes for drugs
• . . .
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 4 / 29
Where do people use Bayesian inference?
• Finance (Quantopian): estimating the performance of trading algorithms
• Music Streaming (Sounds): A/B testing, churn prediction, lifetime value, defining user
session
• E-Commerce (Salesforce): A/B tests, combining disparate sources of information,
hierarchical models
• Astronomy: estimating orbits of space objects, getting an image of a black hole
• Life science: epidemic analysis
• Medicine: calculating effect sizes for drugs
• . . .
Some will be covered later
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 4 / 29
Coin Example
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 5 / 29
Fair Coin Flips – expect fair
p ∼ Beta(3, 3)
flips ∼ Binomial(N, p)
Data: 12 out of 20 flips
What is p?
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 6 / 29
Fair Coin Flips – expect fair
p ∼ Beta(3, 3)
flips ∼ Binomial(N, p)
Data: 12 out of 20 flips
What is p?
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 6 / 29
Fair Coin Flips – expect fair
p ∼ Beta(3, 3)
flips ∼ Binomial(N, p)
Data: 12 out of 20 flips
What is p?
We expect an angel and see an angel, we are confident
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 6 / 29
Fair Coin Flips – expect unfair
What is p?
p ∼ Beta(1, 5)
flips ∼ Binomial(N, p)
Data: 12 out of 20 flips
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 7 / 29
Fair Coin Flips – expect unfair
What is p?
p ∼ Beta(1, 5)
flips ∼ Binomial(N, p)
Data: 12 out of 20 flips
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 7 / 29
Fair Coin Flips – expect unfair
What is p?
p ∼ Beta(1, 5)
flips ∼ Binomial(N, p)
Data: 12 out of 20 flips
We expect a devil but see an angel, we are less confident
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 7 / 29
Hierarchical Models
What if we have more diverse data? We can estimate an amount of devils + uncertainty!
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 8 / 29
Hierarchical Models
What if we have more diverse data? We can estimate an amount of devils + uncertainty!
Data: [8, 2, 2, 10, 0,
0, 2, 5, 6, 10] out of 20 flips
λDevil ∼ Exponential(1)
λAngel ∼ Exponential(1)
pi ∼ Beta(λAngel , λAngel + λDevil )
flipsi ∼ Binomial(pi , Ni )
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 8 / 29
Hierarchical Models
What if we have more diverse data? We can estimate an amount of devils + uncertainty!
Data: [8, 2, 2, 10, 0,
0, 2, 5, 6, 10] out of 20 flips
λDevil ∼ Exponential(1)
λAngel ∼ Exponential(1)
pi ∼ Beta(λAngel , λAngel + λDevil )
flipsi ∼ Binomial(pi , Ni )
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 8 / 29
Markov Chain Monte Carlo (MCMC) & Variational Inference
Few simple rules
• Try MCMC first
• If it is slow: wait a bit
• Got tired: try VI
• Didn’t work: feel sad
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 9 / 29
Markov Chain Monte Carlo (MCMC) & Variational Inference
Few simple rules
• Try MCMC first
• If it is slow: wait a bit
• Got tired: try VI
• Didn’t work: feel sad
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 9 / 29
Markov Chain Monte Carlo (MCMC) & Variational Inference
Few simple rules
• Try MCMC first
• If it is slow: wait a bit
• Got tired: try VI
• Didn’t work: feel sad
Did not work for you?
goto https://discourse.pymc.io
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 9 / 29
Inspecting Your Model
What is an amount of devils? (MCMC used) pm.traceplot(trace)
0 1 2 3 4 5 6 7 8
0.0
0.2
0.4
Frequency
devils
0 100 200 300 400 500
0.0
2.5
5.0
7.5
Samplevalue
devils
0.5 1.0 1.5 2.0 2.5
0.0
0.5
1.0
Frequency
angels
0 100 200 300 400 500
1
2
Samplevalue
angels
0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8
0
10
20
Frequency
p
0 100 200 300 400 500
0.00
0.25
0.50
0.75
Samplevalue
p
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 10 / 29
Inspecting Your Model
plt.hist(trace["angels"],
alpha=.8, label='Alpha')
plt.hist(trace["angels"]+trace["devils"],
alpha=.8, label='Beta')
plt.legend(fontsize=20)
0 1 2 3 4 5 6 7 8
0
50
100
150
200
250
300
Alpha
Beta
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 11 / 29
Inspecting Your Model
0.0 0.2 0.4 0.6 0.8 1.0
0
1
2
3
4
5
6
7
Prob Distribution
for a, b in zip(
trace["angels"],
trace["angels"]+trace["devils"]
):
plt.plot(
np.linspace(0, 1),
st.beta(a, b).pdf(np.linspace(0, 1)),
color="b", alpha=.025
)
a_mean = trace["angels"].mean()
b_mean = (trace["angels"]+trace["devils"]).mean()
plt.plot(
np.linspace(0, 1),
st.beta(a_mean, b_mean).pdf(np.linspace(0, 1)),
color="black", linewidth=4.0
)
plt.axvline(0.5)
plt.title("Prob Distribution", fontsize=20)
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 12 / 29
Case Studies
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 13 / 29
A/B testing
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 14 / 29
A/B testing, why Bayes
We would accept that
result
0.0 0.2 0.4 0.6 0.8 1.0
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
p-val=0.2398diff=0.1
diff=0.1
pval=.24
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 15 / 29
A/B testing, why Bayes
We would accept that
result
0.0 0.2 0.4 0.6 0.8 1.0
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
p-val=0.2398diff=0.1
diff=0.1
pval=.24
We wait too long to
check small diff
0.0 0.2 0.4 0.6 0.8 1.0
0
5
10
15
20
25
30
35
40
p-val=0.2398diff=0.01
diff=0.01
pval=.24
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 15 / 29
A/B testing, why Bayes
We would accept that
result
0.0 0.2 0.4 0.6 0.8 1.0
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
p-val=0.2398diff=0.1
diff=0.1
pval=.24
We wait too long to
check small diff
0.0 0.2 0.4 0.6 0.8 1.0
0
5
10
15
20
25
30
35
40
p-val=0.2398diff=0.01
diff=0.01
pval=.24
WTF?
0.0 0.2 0.4 0.6 0.8 1.0
0
5
10
15
20
25
30
35
40
p-val=0.0786diff=0.02
diff=0.02
pval=0.07
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 15 / 29
Expected Loss Framework
p-values are useless. What about calculating a loss of ignoring a better model?
• We now decide to use model A or B
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 16 / 29
Expected Loss Framework
p-values are useless. What about calculating a loss of ignoring a better model?
• We now decide to use model A or B
• A has some α ctr, B has some β ctr
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 16 / 29
Expected Loss Framework
p-values are useless. What about calculating a loss of ignoring a better model?
• We now decide to use model A or B
• A has some α ctr, B has some β ctr
• Say a loss (can be any) to ignore a better model given we use x
Loss(α, β, x) =
max(β − α, 0), x = A
max(α − β, 0), x = B
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 16 / 29
Expected Loss Framework
p-values are useless. What about calculating a loss of ignoring a better model?
• We now decide to use model A or B
• A has some α ctr, B has some β ctr
• Say a loss (can be any) to ignore a better model given we use x
Loss(α, β, x) =
max(β − α, 0), x = A
max(α − β, 0), x = B
• Loss depends on the magnitude of difference (p-values do not)
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 16 / 29
Expected Loss Framework
L(x) = Ep(α,β)Loss(α, β, x) → min
x
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 17 / 29
Expected Loss Framework
L(x) = Ep(α,β)Loss(α, β, x) → min
x
0.0 0.2 0.4 0.6 0.8 1.0
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
p-val=0.2398diff=0.1
L(A) = 0.122
L(B) = 0.019
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 17 / 29
Expected Loss Framework
L(x) = Ep(α,β)Loss(α, β, x) → min
x
0.0 0.2 0.4 0.6 0.8 1.0
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
p-val=0.2398diff=0.1
L(A) = 0.122
L(B) = 0.019
0.0 0.2 0.4 0.6 0.8 1.0
0
5
10
15
20
25
30
35
40
p-val=0.2398diff=0.01
L(A) = 0.012
L(B) = 0.002
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 17 / 29
Expected Loss Framework
L(x) = Ep(α,β)Loss(α, β, x) → min
x
0.0 0.2 0.4 0.6 0.8 1.0
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
p-val=0.2398diff=0.1
L(A) = 0.122
L(B) = 0.019
0.0 0.2 0.4 0.6 0.8 1.0
0
5
10
15
20
25
30
35
40
p-val=0.2398diff=0.01
L(A) = 0.012
L(B) = 0.002
0.0 0.2 0.4 0.6 0.8 1.0
0
5
10
15
20
25
30
35
40
p-val=0.0786diff=0.02
L(A) = 0.02
L(B) = 0.0005
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 17 / 29
Expected Loss Framework
L(x) = Ep(α,β)Loss(α, β, x) → min
x
0.0 0.2 0.4 0.6 0.8 1.0
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
p-val=0.2398diff=0.1
L(A) = 0.122
L(B) = 0.019
0.0 0.2 0.4 0.6 0.8 1.0
0
5
10
15
20
25
30
35
40
p-val=0.2398diff=0.01
L(A) = 0.012
L(B) = 0.002
0.0 0.2 0.4 0.6 0.8 1.0
0
5
10
15
20
25
30
35
40
p-val=0.0786diff=0.02
L(A) = 0.02
L(B) = 0.0005
Without p-values we stop first experiment earlier as B is a clear winner
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 17 / 29
Real(!) Impact of prior
Do you believe in ctr > 0.9 ? Or > 0.8? Or 0?
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 18 / 29
Real(!) Impact of prior
Do you believe in ctr > 0.9 ? Or > 0.8? Or 0?
You have your p(ctr) in mind, use it!
Informative prior
Non-Informative
prior
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 18 / 29
Real(!) Impact of prior
Do you believe in ctr > 0.9 ? Or > 0.8? Or 0?
You have your p(ctr) in mind, use it!
• You iterate quicker
• Accept small improvements
• Fewer problems of continuous monitoring
Informative prior
Non-Informative
prior
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 18 / 29
Real(!) Impact of prior
Do you believe in ctr > 0.9 ? Or > 0.8? Or 0?
You have your p(ctr) in mind, use it!
• You iterate quicker
• Accept small improvements
• Fewer problems of continuous monitoring
Do not use overconfident prior, choose slightly pessimistic one
Informative prior
Non-Informative
prior
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 18 / 29
Real(!) Impact of prior
Do you believe in ctr > 0.9 ? Or > 0.8? Or 0?
You have your p(ctr) in mind, use it!
• You iterate quicker
• Accept small improvements
• Fewer problems of continuous monitoring
Do not use overconfident prior, choose slightly pessimistic one
Choose smarter loss (”accept improvement at least δ”):
Loss(α, β, δ, x) =
max((β − δ) − α, 0), x = A
max(α − (β − δ), 0), x = B
Informative prior
Non-Informative
prior
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 18 / 29
Real(!) Impact of prior
Do you believe in ctr > 0.9 ? Or > 0.8? Or 0?
You have your p(ctr) in mind, use it!
• You iterate quicker
• Accept small improvements
• Fewer problems of continuous monitoring
Do not use overconfident prior, choose slightly pessimistic one
Choose smarter loss (”accept improvement at least δ”):
Loss(α, β, δ, x) =
max((β − δ) − α, 0), x = A
max(α − (β − δ), 0), x = B
Convert loss into $$$
Informative prior
Non-Informative
prior
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 18 / 29
Portfolio
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 19 / 29
Finance (Quantopian) case
Hedge-Fund in Boston
• Crowd sourcing for trade strategies, more that 700k
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 20 / 29
Finance (Quantopian) case
Hedge-Fund in Boston
• Crowd sourcing for trade strategies, more that 700k
• People tend to overfit the leaderboard, that’s ok
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 20 / 29
Finance (Quantopian) case
Hedge-Fund in Boston
• Crowd sourcing for trade strategies, more that 700k
• People tend to overfit the leaderboard, that’s ok
• But they do not have out of sample data
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 20 / 29
Finance (Quantopian) case
Hedge-Fund in Boston
• Crowd sourcing for trade strategies, more that 700k
• People tend to overfit the leaderboard, that’s ok
• But they do not have out of sample data
• Data changes over time, we should take care of it
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 20 / 29
Finance (Quantopian) case
Hedge-Fund in Boston
• Crowd sourcing for trade strategies, more that 700k
• People tend to overfit the leaderboard, that’s ok
• But they do not have out of sample data
• Data changes over time, we should take care of it
How to link 2 periods of algorithm evaluation to use more data?
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 20 / 29
Finance (Quantopian) case
Core ideas
• Use Gaussian process to capture changing
volatility and return in time
Figure: Gaussian Process
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 21 / 29
Finance (Quantopian) case
Core ideas
• Use Gaussian process to capture changing
volatility and return in time
• Allow structural changes in the model
• mean returns
• but not volatility
Figure: Gaussian Process
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 21 / 29
Finance (Quantopian) case
Core ideas
• Use Gaussian process to capture changing
volatility and return in time
• Allow structural changes in the model
• mean returns
• but not volatility
• Use posterior model returns to optimize
expected risk-return objective
Figure: Risk vs Returns
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 21 / 29
Finance (Quantopian) case
Figure: Sharpe Ratio
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 22 / 29
Supply chains
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 23 / 29
year 3019, PyMC X
Supply PyMC X Demand Mars
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 24 / 29
Supply
Business Effect / Observed
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 25 / 29
Demand
∼100 /month
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 26 / 29
Costs and Profits
Profit ∼ Stock | Demand Profit ∼ Demand | Stock
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 27 / 29
Costs and Profits
Profit ∼ Stock | Demand Profit ∼ Demand | Stock
How to combine them?
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 27 / 29
Expected Loss Framework
Profits: Frequentist vs Bayesian
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 28 / 29
Take outs
Bayesian Framework allows:
• effectively use your prior knowledge
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 29 / 29
Take outs
Bayesian Framework allows:
• effectively use your prior knowledge
• take uncertainty in account
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 29 / 29
Take outs
Bayesian Framework allows:
• effectively use your prior knowledge
• take uncertainty in account
• understand your data / problem better
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 29 / 29
Take outs
Bayesian Framework allows:
• effectively use your prior knowledge
• take uncertainty in account
• understand your data / problem better
BUT, you should really understand your problem
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 29 / 29
Take outs
Bayesian Framework allows:
• effectively use your prior knowledge
• take uncertainty in account
• understand your data / problem better
BUT, you should really understand your problem
Tutorials/MISC:
pymc3 docs: https://docs.pymc.io/nb_tutorials/index.html
case studies: https://twiecki.io
Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 29 / 29

Weitere ähnliche Inhalte

Ähnlich wie PyMC3 — Bayesian Statistical Modelling in Python, Максим Кочуров. 22 июня, 2019

Invited Talk: Early Detection of Research Topics
Invited Talk: Early Detection of Research Topics Invited Talk: Early Detection of Research Topics
Invited Talk: Early Detection of Research Topics Angelo Salatino
 
ReComp: Preserving the value of large scale data analytics over time through...
ReComp:Preserving the value of large scale data analytics over time through...ReComp:Preserving the value of large scale data analytics over time through...
ReComp: Preserving the value of large scale data analytics over time through...Paolo Missier
 
The lifecycle of reproducible science data and what provenance has got to do ...
The lifecycle of reproducible science data and what provenance has got to do ...The lifecycle of reproducible science data and what provenance has got to do ...
The lifecycle of reproducible science data and what provenance has got to do ...Paolo Missier
 
La résolution de problèmes à l'aide de graphes
La résolution de problèmes à l'aide de graphesLa résolution de problèmes à l'aide de graphes
La résolution de problèmes à l'aide de graphesData2B
 
Computation and Knowledge
Computation and KnowledgeComputation and Knowledge
Computation and KnowledgeIan Foster
 
Event-based MultiMedia Search and Retrieval for Question Answering
Event-based MultiMedia Search and Retrieval for Question AnsweringEvent-based MultiMedia Search and Retrieval for Question Answering
Event-based MultiMedia Search and Retrieval for Question AnsweringBenoit HUET
 
From the Big Bang to Ecommerce, a journey in making sense of Big Data
From the Big Bang to Ecommerce, a journey in making sense of Big DataFrom the Big Bang to Ecommerce, a journey in making sense of Big Data
From the Big Bang to Ecommerce, a journey in making sense of Big DataPatrick Deglon
 
Probabilistic Modelling with Information Filtering Networks
Probabilistic Modelling with Information Filtering NetworksProbabilistic Modelling with Information Filtering Networks
Probabilistic Modelling with Information Filtering NetworksTomaso Aste
 
How You Can Use Open Source Materials to Learn Python & Data Science - EuroPy...
How You Can Use Open Source Materials to Learn Python & Data Science - EuroPy...How You Can Use Open Source Materials to Learn Python & Data Science - EuroPy...
How You Can Use Open Source Materials to Learn Python & Data Science - EuroPy...Kamila Stępniowska
 
Moving forward data centric sciences weaving AI, Big Data & HPC
Moving forward data centric sciences  weaving AI, Big Data & HPCMoving forward data centric sciences  weaving AI, Big Data & HPC
Moving forward data centric sciences weaving AI, Big Data & HPCGenoveva Vargas-Solar
 
Approaches for the Integration of Visual and Computational Analysis of Biomed...
Approaches for the Integration of Visual and Computational Analysis of Biomed...Approaches for the Integration of Visual and Computational Analysis of Biomed...
Approaches for the Integration of Visual and Computational Analysis of Biomed...Nils Gehlenborg
 
Bayesian Network Modeling using Python and R
Bayesian Network Modeling using Python and RBayesian Network Modeling using Python and R
Bayesian Network Modeling using Python and RPyData
 
PyData DC 2016 Talk: Bayesian Network Modeling Using Python and R
PyData DC 2016 Talk: Bayesian Network Modeling Using Python and RPyData DC 2016 Talk: Bayesian Network Modeling Using Python and R
PyData DC 2016 Talk: Bayesian Network Modeling Using Python and RPragyansmita Nayak, Ph.D.
 
Improving Question Answering by Bridging Linguistic Structures with Statistic...
Improving Question Answering by Bridging Linguistic Structures with Statistic...Improving Question Answering by Bridging Linguistic Structures with Statistic...
Improving Question Answering by Bridging Linguistic Structures with Statistic...Jinho Choi
 
Collective Mind infrastructure and repository to crowdsource auto-tuning (c-m...
Collective Mind infrastructure and repository to crowdsource auto-tuning (c-m...Collective Mind infrastructure and repository to crowdsource auto-tuning (c-m...
Collective Mind infrastructure and repository to crowdsource auto-tuning (c-m...Grigori Fursin
 

Ähnlich wie PyMC3 — Bayesian Statistical Modelling in Python, Максим Кочуров. 22 июня, 2019 (20)

Why Data Science is a Science
Why Data Science is a ScienceWhy Data Science is a Science
Why Data Science is a Science
 
Invited Talk: Early Detection of Research Topics
Invited Talk: Early Detection of Research Topics Invited Talk: Early Detection of Research Topics
Invited Talk: Early Detection of Research Topics
 
UseR 2017
UseR 2017UseR 2017
UseR 2017
 
ReComp: Preserving the value of large scale data analytics over time through...
ReComp:Preserving the value of large scale data analytics over time through...ReComp:Preserving the value of large scale data analytics over time through...
ReComp: Preserving the value of large scale data analytics over time through...
 
The lifecycle of reproducible science data and what provenance has got to do ...
The lifecycle of reproducible science data and what provenance has got to do ...The lifecycle of reproducible science data and what provenance has got to do ...
The lifecycle of reproducible science data and what provenance has got to do ...
 
La résolution de problèmes à l'aide de graphes
La résolution de problèmes à l'aide de graphesLa résolution de problèmes à l'aide de graphes
La résolution de problèmes à l'aide de graphes
 
Computation and Knowledge
Computation and KnowledgeComputation and Knowledge
Computation and Knowledge
 
2015 illinois-talk
2015 illinois-talk2015 illinois-talk
2015 illinois-talk
 
Event-based MultiMedia Search and Retrieval for Question Answering
Event-based MultiMedia Search and Retrieval for Question AnsweringEvent-based MultiMedia Search and Retrieval for Question Answering
Event-based MultiMedia Search and Retrieval for Question Answering
 
From the Big Bang to Ecommerce, a journey in making sense of Big Data
From the Big Bang to Ecommerce, a journey in making sense of Big DataFrom the Big Bang to Ecommerce, a journey in making sense of Big Data
From the Big Bang to Ecommerce, a journey in making sense of Big Data
 
Probabilistic Modelling with Information Filtering Networks
Probabilistic Modelling with Information Filtering NetworksProbabilistic Modelling with Information Filtering Networks
Probabilistic Modelling with Information Filtering Networks
 
Recommandation sociale : filtrage collaboratif et par le contenu
Recommandation sociale : filtrage collaboratif et par le contenuRecommandation sociale : filtrage collaboratif et par le contenu
Recommandation sociale : filtrage collaboratif et par le contenu
 
How You Can Use Open Source Materials to Learn Python & Data Science - EuroPy...
How You Can Use Open Source Materials to Learn Python & Data Science - EuroPy...How You Can Use Open Source Materials to Learn Python & Data Science - EuroPy...
How You Can Use Open Source Materials to Learn Python & Data Science - EuroPy...
 
Moving forward data centric sciences weaving AI, Big Data & HPC
Moving forward data centric sciences  weaving AI, Big Data & HPCMoving forward data centric sciences  weaving AI, Big Data & HPC
Moving forward data centric sciences weaving AI, Big Data & HPC
 
ConQueSt
ConQueStConQueSt
ConQueSt
 
Approaches for the Integration of Visual and Computational Analysis of Biomed...
Approaches for the Integration of Visual and Computational Analysis of Biomed...Approaches for the Integration of Visual and Computational Analysis of Biomed...
Approaches for the Integration of Visual and Computational Analysis of Biomed...
 
Bayesian Network Modeling using Python and R
Bayesian Network Modeling using Python and RBayesian Network Modeling using Python and R
Bayesian Network Modeling using Python and R
 
PyData DC 2016 Talk: Bayesian Network Modeling Using Python and R
PyData DC 2016 Talk: Bayesian Network Modeling Using Python and RPyData DC 2016 Talk: Bayesian Network Modeling Using Python and R
PyData DC 2016 Talk: Bayesian Network Modeling Using Python and R
 
Improving Question Answering by Bridging Linguistic Structures with Statistic...
Improving Question Answering by Bridging Linguistic Structures with Statistic...Improving Question Answering by Bridging Linguistic Structures with Statistic...
Improving Question Answering by Bridging Linguistic Structures with Statistic...
 
Collective Mind infrastructure and repository to crowdsource auto-tuning (c-m...
Collective Mind infrastructure and repository to crowdsource auto-tuning (c-m...Collective Mind infrastructure and repository to crowdsource auto-tuning (c-m...
Collective Mind infrastructure and repository to crowdsource auto-tuning (c-m...
 

Mehr von Mail.ru Group

Автоматизация без тест-инженеров по автоматизации, Мария Терехина и Владислав...
Автоматизация без тест-инженеров по автоматизации, Мария Терехина и Владислав...Автоматизация без тест-инженеров по автоматизации, Мария Терехина и Владислав...
Автоматизация без тест-инженеров по автоматизации, Мария Терехина и Владислав...Mail.ru Group
 
BDD для фронтенда. Автоматизация тестирования с Cucumber, Cypress и Jenkins, ...
BDD для фронтенда. Автоматизация тестирования с Cucumber, Cypress и Jenkins, ...BDD для фронтенда. Автоматизация тестирования с Cucumber, Cypress и Jenkins, ...
BDD для фронтенда. Автоматизация тестирования с Cucumber, Cypress и Jenkins, ...Mail.ru Group
 
Другая сторона баг-баунти-программ: как это выглядит изнутри, Владимир Дубровин
Другая сторона баг-баунти-программ: как это выглядит изнутри, Владимир ДубровинДругая сторона баг-баунти-программ: как это выглядит изнутри, Владимир Дубровин
Другая сторона баг-баунти-программ: как это выглядит изнутри, Владимир ДубровинMail.ru Group
 
Использование Fiddler и Charles при тестировании фронтенда проекта pulse.mail...
Использование Fiddler и Charles при тестировании фронтенда проекта pulse.mail...Использование Fiddler и Charles при тестировании фронтенда проекта pulse.mail...
Использование Fiddler и Charles при тестировании фронтенда проекта pulse.mail...Mail.ru Group
 
Управление инцидентами в Почте Mail.ru, Антон Викторов
Управление инцидентами в Почте Mail.ru, Антон ВикторовУправление инцидентами в Почте Mail.ru, Антон Викторов
Управление инцидентами в Почте Mail.ru, Антон ВикторовMail.ru Group
 
DAST в CI/CD, Ольга Свиридова
DAST в CI/CD, Ольга СвиридоваDAST в CI/CD, Ольга Свиридова
DAST в CI/CD, Ольга СвиридоваMail.ru Group
 
Почему вам стоит использовать свой велосипед и почему не стоит Александр Бел...
Почему вам стоит использовать свой велосипед и почему не стоит  Александр Бел...Почему вам стоит использовать свой велосипед и почему не стоит  Александр Бел...
Почему вам стоит использовать свой велосипед и почему не стоит Александр Бел...Mail.ru Group
 
CV в пайплайне распознавания ценников товаров: трюки и хитрости Николай Масл...
CV в пайплайне распознавания ценников товаров: трюки и хитрости  Николай Масл...CV в пайплайне распознавания ценников товаров: трюки и хитрости  Николай Масл...
CV в пайплайне распознавания ценников товаров: трюки и хитрости Николай Масл...Mail.ru Group
 
RAPIDS: ускоряем Pandas и scikit-learn на GPU Павел Клеменков, NVidia
RAPIDS: ускоряем Pandas и scikit-learn на GPU  Павел Клеменков, NVidiaRAPIDS: ускоряем Pandas и scikit-learn на GPU  Павел Клеменков, NVidia
RAPIDS: ускоряем Pandas и scikit-learn на GPU Павел Клеменков, NVidiaMail.ru Group
 
WebAuthn в реальной жизни, Анатолий Остапенко
WebAuthn в реальной жизни, Анатолий ОстапенкоWebAuthn в реальной жизни, Анатолий Остапенко
WebAuthn в реальной жизни, Анатолий ОстапенкоMail.ru Group
 
AMP для электронной почты, Сергей Пешков
AMP для электронной почты, Сергей ПешковAMP для электронной почты, Сергей Пешков
AMP для электронной почты, Сергей ПешковMail.ru Group
 
Как мы захотели TWA и сделали его без мобильных разработчиков, Данила Стрелков
Как мы захотели TWA и сделали его без мобильных разработчиков, Данила СтрелковКак мы захотели TWA и сделали его без мобильных разработчиков, Данила Стрелков
Как мы захотели TWA и сделали его без мобильных разработчиков, Данила СтрелковMail.ru Group
 
Кейсы использования PWA для партнерских предложений в Delivery Club, Никита Б...
Кейсы использования PWA для партнерских предложений в Delivery Club, Никита Б...Кейсы использования PWA для партнерских предложений в Delivery Club, Никита Б...
Кейсы использования PWA для партнерских предложений в Delivery Club, Никита Б...Mail.ru Group
 
Метапрограммирование: строим конечный автомат, Сергей Федоров, Яндекс.Такси
Метапрограммирование: строим конечный автомат, Сергей Федоров, Яндекс.ТаксиМетапрограммирование: строим конечный автомат, Сергей Федоров, Яндекс.Такси
Метапрограммирование: строим конечный автомат, Сергей Федоров, Яндекс.ТаксиMail.ru Group
 
Как не сделать врагами архитектуру и оптимизацию, Кирилл Березин, Mail.ru Group
Как не сделать врагами архитектуру и оптимизацию, Кирилл Березин, Mail.ru GroupКак не сделать врагами архитектуру и оптимизацию, Кирилл Березин, Mail.ru Group
Как не сделать врагами архитектуру и оптимизацию, Кирилл Березин, Mail.ru GroupMail.ru Group
 
Этика искусственного интеллекта, Александр Кармаев (AI Journey)
Этика искусственного интеллекта, Александр Кармаев (AI Journey)Этика искусственного интеллекта, Александр Кармаев (AI Journey)
Этика искусственного интеллекта, Александр Кармаев (AI Journey)Mail.ru Group
 
Нейро-машинный перевод в вопросно-ответных системах, Федор Федоренко (AI Jour...
Нейро-машинный перевод в вопросно-ответных системах, Федор Федоренко (AI Jour...Нейро-машинный перевод в вопросно-ответных системах, Федор Федоренко (AI Jour...
Нейро-машинный перевод в вопросно-ответных системах, Федор Федоренко (AI Jour...Mail.ru Group
 
Конвергенция технологий как тренд развития искусственного интеллекта, Владими...
Конвергенция технологий как тренд развития искусственного интеллекта, Владими...Конвергенция технологий как тренд развития искусственного интеллекта, Владими...
Конвергенция технологий как тренд развития искусственного интеллекта, Владими...Mail.ru Group
 
Обзор трендов рекомендательных систем от Пульса, Андрей Мурашев (AI Journey)
Обзор трендов рекомендательных систем от Пульса, Андрей Мурашев (AI Journey)Обзор трендов рекомендательных систем от Пульса, Андрей Мурашев (AI Journey)
Обзор трендов рекомендательных систем от Пульса, Андрей Мурашев (AI Journey)Mail.ru Group
 
Мир глазами нейросетей, Данила Байгушев, Александр Сноркин ()
Мир глазами нейросетей, Данила Байгушев, Александр Сноркин ()Мир глазами нейросетей, Данила Байгушев, Александр Сноркин ()
Мир глазами нейросетей, Данила Байгушев, Александр Сноркин ()Mail.ru Group
 

Mehr von Mail.ru Group (20)

Автоматизация без тест-инженеров по автоматизации, Мария Терехина и Владислав...
Автоматизация без тест-инженеров по автоматизации, Мария Терехина и Владислав...Автоматизация без тест-инженеров по автоматизации, Мария Терехина и Владислав...
Автоматизация без тест-инженеров по автоматизации, Мария Терехина и Владислав...
 
BDD для фронтенда. Автоматизация тестирования с Cucumber, Cypress и Jenkins, ...
BDD для фронтенда. Автоматизация тестирования с Cucumber, Cypress и Jenkins, ...BDD для фронтенда. Автоматизация тестирования с Cucumber, Cypress и Jenkins, ...
BDD для фронтенда. Автоматизация тестирования с Cucumber, Cypress и Jenkins, ...
 
Другая сторона баг-баунти-программ: как это выглядит изнутри, Владимир Дубровин
Другая сторона баг-баунти-программ: как это выглядит изнутри, Владимир ДубровинДругая сторона баг-баунти-программ: как это выглядит изнутри, Владимир Дубровин
Другая сторона баг-баунти-программ: как это выглядит изнутри, Владимир Дубровин
 
Использование Fiddler и Charles при тестировании фронтенда проекта pulse.mail...
Использование Fiddler и Charles при тестировании фронтенда проекта pulse.mail...Использование Fiddler и Charles при тестировании фронтенда проекта pulse.mail...
Использование Fiddler и Charles при тестировании фронтенда проекта pulse.mail...
 
Управление инцидентами в Почте Mail.ru, Антон Викторов
Управление инцидентами в Почте Mail.ru, Антон ВикторовУправление инцидентами в Почте Mail.ru, Антон Викторов
Управление инцидентами в Почте Mail.ru, Антон Викторов
 
DAST в CI/CD, Ольга Свиридова
DAST в CI/CD, Ольга СвиридоваDAST в CI/CD, Ольга Свиридова
DAST в CI/CD, Ольга Свиридова
 
Почему вам стоит использовать свой велосипед и почему не стоит Александр Бел...
Почему вам стоит использовать свой велосипед и почему не стоит  Александр Бел...Почему вам стоит использовать свой велосипед и почему не стоит  Александр Бел...
Почему вам стоит использовать свой велосипед и почему не стоит Александр Бел...
 
CV в пайплайне распознавания ценников товаров: трюки и хитрости Николай Масл...
CV в пайплайне распознавания ценников товаров: трюки и хитрости  Николай Масл...CV в пайплайне распознавания ценников товаров: трюки и хитрости  Николай Масл...
CV в пайплайне распознавания ценников товаров: трюки и хитрости Николай Масл...
 
RAPIDS: ускоряем Pandas и scikit-learn на GPU Павел Клеменков, NVidia
RAPIDS: ускоряем Pandas и scikit-learn на GPU  Павел Клеменков, NVidiaRAPIDS: ускоряем Pandas и scikit-learn на GPU  Павел Клеменков, NVidia
RAPIDS: ускоряем Pandas и scikit-learn на GPU Павел Клеменков, NVidia
 
WebAuthn в реальной жизни, Анатолий Остапенко
WebAuthn в реальной жизни, Анатолий ОстапенкоWebAuthn в реальной жизни, Анатолий Остапенко
WebAuthn в реальной жизни, Анатолий Остапенко
 
AMP для электронной почты, Сергей Пешков
AMP для электронной почты, Сергей ПешковAMP для электронной почты, Сергей Пешков
AMP для электронной почты, Сергей Пешков
 
Как мы захотели TWA и сделали его без мобильных разработчиков, Данила Стрелков
Как мы захотели TWA и сделали его без мобильных разработчиков, Данила СтрелковКак мы захотели TWA и сделали его без мобильных разработчиков, Данила Стрелков
Как мы захотели TWA и сделали его без мобильных разработчиков, Данила Стрелков
 
Кейсы использования PWA для партнерских предложений в Delivery Club, Никита Б...
Кейсы использования PWA для партнерских предложений в Delivery Club, Никита Б...Кейсы использования PWA для партнерских предложений в Delivery Club, Никита Б...
Кейсы использования PWA для партнерских предложений в Delivery Club, Никита Б...
 
Метапрограммирование: строим конечный автомат, Сергей Федоров, Яндекс.Такси
Метапрограммирование: строим конечный автомат, Сергей Федоров, Яндекс.ТаксиМетапрограммирование: строим конечный автомат, Сергей Федоров, Яндекс.Такси
Метапрограммирование: строим конечный автомат, Сергей Федоров, Яндекс.Такси
 
Как не сделать врагами архитектуру и оптимизацию, Кирилл Березин, Mail.ru Group
Как не сделать врагами архитектуру и оптимизацию, Кирилл Березин, Mail.ru GroupКак не сделать врагами архитектуру и оптимизацию, Кирилл Березин, Mail.ru Group
Как не сделать врагами архитектуру и оптимизацию, Кирилл Березин, Mail.ru Group
 
Этика искусственного интеллекта, Александр Кармаев (AI Journey)
Этика искусственного интеллекта, Александр Кармаев (AI Journey)Этика искусственного интеллекта, Александр Кармаев (AI Journey)
Этика искусственного интеллекта, Александр Кармаев (AI Journey)
 
Нейро-машинный перевод в вопросно-ответных системах, Федор Федоренко (AI Jour...
Нейро-машинный перевод в вопросно-ответных системах, Федор Федоренко (AI Jour...Нейро-машинный перевод в вопросно-ответных системах, Федор Федоренко (AI Jour...
Нейро-машинный перевод в вопросно-ответных системах, Федор Федоренко (AI Jour...
 
Конвергенция технологий как тренд развития искусственного интеллекта, Владими...
Конвергенция технологий как тренд развития искусственного интеллекта, Владими...Конвергенция технологий как тренд развития искусственного интеллекта, Владими...
Конвергенция технологий как тренд развития искусственного интеллекта, Владими...
 
Обзор трендов рекомендательных систем от Пульса, Андрей Мурашев (AI Journey)
Обзор трендов рекомендательных систем от Пульса, Андрей Мурашев (AI Journey)Обзор трендов рекомендательных систем от Пульса, Андрей Мурашев (AI Journey)
Обзор трендов рекомендательных систем от Пульса, Андрей Мурашев (AI Journey)
 
Мир глазами нейросетей, Данила Байгушев, Александр Сноркин ()
Мир глазами нейросетей, Данила Байгушев, Александр Сноркин ()Мир глазами нейросетей, Данила Байгушев, Александр Сноркин ()
Мир глазами нейросетей, Данила Байгушев, Александр Сноркин ()
 

Kürzlich hochgeladen

Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfYashikaSharma391629
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 

Kürzlich hochgeladen (20)

Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 

PyMC3 — Bayesian Statistical Modelling in Python, Максим Кочуров. 22 июня, 2019

  • 1. PyMC3 – Bayesian Statistical Modelling in Python Max Kochurov 22 June, 2019 Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 1 / 29
  • 2. About me Max Kochurov tg,slack:@ferres / github:ferrine Geoopt Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 2 / 29
  • 3. Bayesian Statistics Figure: Updating prior p(λ) p(λ | D) = p(D | λ)p(λ) p(D) • p(λ) – Prior, base knowledge • p(D | λ) – Likelihood, new information • p(λ | D) – Posterior, updated knowledge • p(D) – Evidence, surprise in data Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 3 / 29
  • 4. Bayesian Statistics p(λ | D) = p(D | λ)p(λ) p(D) • p(λ) – Prior, base knowledge • p(D | λ) – Likelihood, new information • p(λ | D) – Posterior, updated knowledge • p(D) – Evidence, surprise in data Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 3 / 29
  • 5. Bayesian Statistics Compared to Frequentist • Elegant way to put assumptions in the model • Can work with few Data! • No need for p-values, all you need is p(λ | D) • . . . p(λ | D) = p(D | λ)p(λ) p(D) • p(λ) – Prior, base knowledge • p(D | λ) – Likelihood, new information • p(λ | D) – Posterior, updated knowledge • p(D) – Evidence, surprise in data Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 3 / 29
  • 6. Where do people use Bayesian inference? • Finance (Quantopian): estimating the performance of trading algorithms Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 4 / 29
  • 7. Where do people use Bayesian inference? • Finance (Quantopian): estimating the performance of trading algorithms • Music Streaming (Sounds): A/B testing, churn prediction, lifetime value, defining user session Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 4 / 29
  • 8. Where do people use Bayesian inference? • Finance (Quantopian): estimating the performance of trading algorithms • Music Streaming (Sounds): A/B testing, churn prediction, lifetime value, defining user session • E-Commerce (Salesforce): A/B tests, combining disparate sources of information, hierarchical models Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 4 / 29
  • 9. Where do people use Bayesian inference? • Finance (Quantopian): estimating the performance of trading algorithms • Music Streaming (Sounds): A/B testing, churn prediction, lifetime value, defining user session • E-Commerce (Salesforce): A/B tests, combining disparate sources of information, hierarchical models • Astronomy: estimating orbits of space objects, getting an image of a black hole Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 4 / 29
  • 10. Where do people use Bayesian inference? • Finance (Quantopian): estimating the performance of trading algorithms • Music Streaming (Sounds): A/B testing, churn prediction, lifetime value, defining user session • E-Commerce (Salesforce): A/B tests, combining disparate sources of information, hierarchical models • Astronomy: estimating orbits of space objects, getting an image of a black hole • Life science: epidemic analysis Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 4 / 29
  • 11. Where do people use Bayesian inference? • Finance (Quantopian): estimating the performance of trading algorithms • Music Streaming (Sounds): A/B testing, churn prediction, lifetime value, defining user session • E-Commerce (Salesforce): A/B tests, combining disparate sources of information, hierarchical models • Astronomy: estimating orbits of space objects, getting an image of a black hole • Life science: epidemic analysis • Medicine: calculating effect sizes for drugs Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 4 / 29
  • 12. Where do people use Bayesian inference? • Finance (Quantopian): estimating the performance of trading algorithms • Music Streaming (Sounds): A/B testing, churn prediction, lifetime value, defining user session • E-Commerce (Salesforce): A/B tests, combining disparate sources of information, hierarchical models • Astronomy: estimating orbits of space objects, getting an image of a black hole • Life science: epidemic analysis • Medicine: calculating effect sizes for drugs • . . . Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 4 / 29
  • 13. Where do people use Bayesian inference? • Finance (Quantopian): estimating the performance of trading algorithms • Music Streaming (Sounds): A/B testing, churn prediction, lifetime value, defining user session • E-Commerce (Salesforce): A/B tests, combining disparate sources of information, hierarchical models • Astronomy: estimating orbits of space objects, getting an image of a black hole • Life science: epidemic analysis • Medicine: calculating effect sizes for drugs • . . . Some will be covered later Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 4 / 29
  • 14. Coin Example Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 5 / 29
  • 15. Fair Coin Flips – expect fair p ∼ Beta(3, 3) flips ∼ Binomial(N, p) Data: 12 out of 20 flips What is p? Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 6 / 29
  • 16. Fair Coin Flips – expect fair p ∼ Beta(3, 3) flips ∼ Binomial(N, p) Data: 12 out of 20 flips What is p? Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 6 / 29
  • 17. Fair Coin Flips – expect fair p ∼ Beta(3, 3) flips ∼ Binomial(N, p) Data: 12 out of 20 flips What is p? We expect an angel and see an angel, we are confident Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 6 / 29
  • 18. Fair Coin Flips – expect unfair What is p? p ∼ Beta(1, 5) flips ∼ Binomial(N, p) Data: 12 out of 20 flips Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 7 / 29
  • 19. Fair Coin Flips – expect unfair What is p? p ∼ Beta(1, 5) flips ∼ Binomial(N, p) Data: 12 out of 20 flips Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 7 / 29
  • 20. Fair Coin Flips – expect unfair What is p? p ∼ Beta(1, 5) flips ∼ Binomial(N, p) Data: 12 out of 20 flips We expect a devil but see an angel, we are less confident Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 7 / 29
  • 21. Hierarchical Models What if we have more diverse data? We can estimate an amount of devils + uncertainty! Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 8 / 29
  • 22. Hierarchical Models What if we have more diverse data? We can estimate an amount of devils + uncertainty! Data: [8, 2, 2, 10, 0, 0, 2, 5, 6, 10] out of 20 flips λDevil ∼ Exponential(1) λAngel ∼ Exponential(1) pi ∼ Beta(λAngel , λAngel + λDevil ) flipsi ∼ Binomial(pi , Ni ) Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 8 / 29
  • 23. Hierarchical Models What if we have more diverse data? We can estimate an amount of devils + uncertainty! Data: [8, 2, 2, 10, 0, 0, 2, 5, 6, 10] out of 20 flips λDevil ∼ Exponential(1) λAngel ∼ Exponential(1) pi ∼ Beta(λAngel , λAngel + λDevil ) flipsi ∼ Binomial(pi , Ni ) Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 8 / 29
  • 24. Markov Chain Monte Carlo (MCMC) & Variational Inference Few simple rules • Try MCMC first • If it is slow: wait a bit • Got tired: try VI • Didn’t work: feel sad Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 9 / 29
  • 25. Markov Chain Monte Carlo (MCMC) & Variational Inference Few simple rules • Try MCMC first • If it is slow: wait a bit • Got tired: try VI • Didn’t work: feel sad Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 9 / 29
  • 26. Markov Chain Monte Carlo (MCMC) & Variational Inference Few simple rules • Try MCMC first • If it is slow: wait a bit • Got tired: try VI • Didn’t work: feel sad Did not work for you? goto https://discourse.pymc.io Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 9 / 29
  • 27. Inspecting Your Model What is an amount of devils? (MCMC used) pm.traceplot(trace) 0 1 2 3 4 5 6 7 8 0.0 0.2 0.4 Frequency devils 0 100 200 300 400 500 0.0 2.5 5.0 7.5 Samplevalue devils 0.5 1.0 1.5 2.0 2.5 0.0 0.5 1.0 Frequency angels 0 100 200 300 400 500 1 2 Samplevalue angels 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0 10 20 Frequency p 0 100 200 300 400 500 0.00 0.25 0.50 0.75 Samplevalue p Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 10 / 29
  • 28. Inspecting Your Model plt.hist(trace["angels"], alpha=.8, label='Alpha') plt.hist(trace["angels"]+trace["devils"], alpha=.8, label='Beta') plt.legend(fontsize=20) 0 1 2 3 4 5 6 7 8 0 50 100 150 200 250 300 Alpha Beta Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 11 / 29
  • 29. Inspecting Your Model 0.0 0.2 0.4 0.6 0.8 1.0 0 1 2 3 4 5 6 7 Prob Distribution for a, b in zip( trace["angels"], trace["angels"]+trace["devils"] ): plt.plot( np.linspace(0, 1), st.beta(a, b).pdf(np.linspace(0, 1)), color="b", alpha=.025 ) a_mean = trace["angels"].mean() b_mean = (trace["angels"]+trace["devils"]).mean() plt.plot( np.linspace(0, 1), st.beta(a_mean, b_mean).pdf(np.linspace(0, 1)), color="black", linewidth=4.0 ) plt.axvline(0.5) plt.title("Prob Distribution", fontsize=20) Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 12 / 29
  • 30. Case Studies Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 13 / 29
  • 31. A/B testing Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 14 / 29
  • 32. A/B testing, why Bayes We would accept that result 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 p-val=0.2398diff=0.1 diff=0.1 pval=.24 Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 15 / 29
  • 33. A/B testing, why Bayes We would accept that result 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 p-val=0.2398diff=0.1 diff=0.1 pval=.24 We wait too long to check small diff 0.0 0.2 0.4 0.6 0.8 1.0 0 5 10 15 20 25 30 35 40 p-val=0.2398diff=0.01 diff=0.01 pval=.24 Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 15 / 29
  • 34. A/B testing, why Bayes We would accept that result 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 p-val=0.2398diff=0.1 diff=0.1 pval=.24 We wait too long to check small diff 0.0 0.2 0.4 0.6 0.8 1.0 0 5 10 15 20 25 30 35 40 p-val=0.2398diff=0.01 diff=0.01 pval=.24 WTF? 0.0 0.2 0.4 0.6 0.8 1.0 0 5 10 15 20 25 30 35 40 p-val=0.0786diff=0.02 diff=0.02 pval=0.07 Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 15 / 29
  • 35. Expected Loss Framework p-values are useless. What about calculating a loss of ignoring a better model? • We now decide to use model A or B Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 16 / 29
  • 36. Expected Loss Framework p-values are useless. What about calculating a loss of ignoring a better model? • We now decide to use model A or B • A has some α ctr, B has some β ctr Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 16 / 29
  • 37. Expected Loss Framework p-values are useless. What about calculating a loss of ignoring a better model? • We now decide to use model A or B • A has some α ctr, B has some β ctr • Say a loss (can be any) to ignore a better model given we use x Loss(α, β, x) = max(β − α, 0), x = A max(α − β, 0), x = B Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 16 / 29
  • 38. Expected Loss Framework p-values are useless. What about calculating a loss of ignoring a better model? • We now decide to use model A or B • A has some α ctr, B has some β ctr • Say a loss (can be any) to ignore a better model given we use x Loss(α, β, x) = max(β − α, 0), x = A max(α − β, 0), x = B • Loss depends on the magnitude of difference (p-values do not) Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 16 / 29
  • 39. Expected Loss Framework L(x) = Ep(α,β)Loss(α, β, x) → min x Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 17 / 29
  • 40. Expected Loss Framework L(x) = Ep(α,β)Loss(α, β, x) → min x 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 p-val=0.2398diff=0.1 L(A) = 0.122 L(B) = 0.019 Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 17 / 29
  • 41. Expected Loss Framework L(x) = Ep(α,β)Loss(α, β, x) → min x 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 p-val=0.2398diff=0.1 L(A) = 0.122 L(B) = 0.019 0.0 0.2 0.4 0.6 0.8 1.0 0 5 10 15 20 25 30 35 40 p-val=0.2398diff=0.01 L(A) = 0.012 L(B) = 0.002 Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 17 / 29
  • 42. Expected Loss Framework L(x) = Ep(α,β)Loss(α, β, x) → min x 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 p-val=0.2398diff=0.1 L(A) = 0.122 L(B) = 0.019 0.0 0.2 0.4 0.6 0.8 1.0 0 5 10 15 20 25 30 35 40 p-val=0.2398diff=0.01 L(A) = 0.012 L(B) = 0.002 0.0 0.2 0.4 0.6 0.8 1.0 0 5 10 15 20 25 30 35 40 p-val=0.0786diff=0.02 L(A) = 0.02 L(B) = 0.0005 Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 17 / 29
  • 43. Expected Loss Framework L(x) = Ep(α,β)Loss(α, β, x) → min x 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 p-val=0.2398diff=0.1 L(A) = 0.122 L(B) = 0.019 0.0 0.2 0.4 0.6 0.8 1.0 0 5 10 15 20 25 30 35 40 p-val=0.2398diff=0.01 L(A) = 0.012 L(B) = 0.002 0.0 0.2 0.4 0.6 0.8 1.0 0 5 10 15 20 25 30 35 40 p-val=0.0786diff=0.02 L(A) = 0.02 L(B) = 0.0005 Without p-values we stop first experiment earlier as B is a clear winner Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 17 / 29
  • 44. Real(!) Impact of prior Do you believe in ctr > 0.9 ? Or > 0.8? Or 0? Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 18 / 29
  • 45. Real(!) Impact of prior Do you believe in ctr > 0.9 ? Or > 0.8? Or 0? You have your p(ctr) in mind, use it! Informative prior Non-Informative prior Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 18 / 29
  • 46. Real(!) Impact of prior Do you believe in ctr > 0.9 ? Or > 0.8? Or 0? You have your p(ctr) in mind, use it! • You iterate quicker • Accept small improvements • Fewer problems of continuous monitoring Informative prior Non-Informative prior Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 18 / 29
  • 47. Real(!) Impact of prior Do you believe in ctr > 0.9 ? Or > 0.8? Or 0? You have your p(ctr) in mind, use it! • You iterate quicker • Accept small improvements • Fewer problems of continuous monitoring Do not use overconfident prior, choose slightly pessimistic one Informative prior Non-Informative prior Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 18 / 29
  • 48. Real(!) Impact of prior Do you believe in ctr > 0.9 ? Or > 0.8? Or 0? You have your p(ctr) in mind, use it! • You iterate quicker • Accept small improvements • Fewer problems of continuous monitoring Do not use overconfident prior, choose slightly pessimistic one Choose smarter loss (”accept improvement at least δ”): Loss(α, β, δ, x) = max((β − δ) − α, 0), x = A max(α − (β − δ), 0), x = B Informative prior Non-Informative prior Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 18 / 29
  • 49. Real(!) Impact of prior Do you believe in ctr > 0.9 ? Or > 0.8? Or 0? You have your p(ctr) in mind, use it! • You iterate quicker • Accept small improvements • Fewer problems of continuous monitoring Do not use overconfident prior, choose slightly pessimistic one Choose smarter loss (”accept improvement at least δ”): Loss(α, β, δ, x) = max((β − δ) − α, 0), x = A max(α − (β − δ), 0), x = B Convert loss into $$$ Informative prior Non-Informative prior Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 18 / 29
  • 50. Portfolio Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 19 / 29
  • 51. Finance (Quantopian) case Hedge-Fund in Boston • Crowd sourcing for trade strategies, more that 700k Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 20 / 29
  • 52. Finance (Quantopian) case Hedge-Fund in Boston • Crowd sourcing for trade strategies, more that 700k • People tend to overfit the leaderboard, that’s ok Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 20 / 29
  • 53. Finance (Quantopian) case Hedge-Fund in Boston • Crowd sourcing for trade strategies, more that 700k • People tend to overfit the leaderboard, that’s ok • But they do not have out of sample data Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 20 / 29
  • 54. Finance (Quantopian) case Hedge-Fund in Boston • Crowd sourcing for trade strategies, more that 700k • People tend to overfit the leaderboard, that’s ok • But they do not have out of sample data • Data changes over time, we should take care of it Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 20 / 29
  • 55. Finance (Quantopian) case Hedge-Fund in Boston • Crowd sourcing for trade strategies, more that 700k • People tend to overfit the leaderboard, that’s ok • But they do not have out of sample data • Data changes over time, we should take care of it How to link 2 periods of algorithm evaluation to use more data? Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 20 / 29
  • 56. Finance (Quantopian) case Core ideas • Use Gaussian process to capture changing volatility and return in time Figure: Gaussian Process Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 21 / 29
  • 57. Finance (Quantopian) case Core ideas • Use Gaussian process to capture changing volatility and return in time • Allow structural changes in the model • mean returns • but not volatility Figure: Gaussian Process Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 21 / 29
  • 58. Finance (Quantopian) case Core ideas • Use Gaussian process to capture changing volatility and return in time • Allow structural changes in the model • mean returns • but not volatility • Use posterior model returns to optimize expected risk-return objective Figure: Risk vs Returns Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 21 / 29
  • 59. Finance (Quantopian) case Figure: Sharpe Ratio Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 22 / 29
  • 60. Supply chains Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 23 / 29
  • 61. year 3019, PyMC X Supply PyMC X Demand Mars Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 24 / 29
  • 62. Supply Business Effect / Observed Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 25 / 29
  • 63. Demand ∼100 /month Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 26 / 29
  • 64. Costs and Profits Profit ∼ Stock | Demand Profit ∼ Demand | Stock Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 27 / 29
  • 65. Costs and Profits Profit ∼ Stock | Demand Profit ∼ Demand | Stock How to combine them? Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 27 / 29
  • 66. Expected Loss Framework Profits: Frequentist vs Bayesian Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 28 / 29
  • 67. Take outs Bayesian Framework allows: • effectively use your prior knowledge Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 29 / 29
  • 68. Take outs Bayesian Framework allows: • effectively use your prior knowledge • take uncertainty in account Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 29 / 29
  • 69. Take outs Bayesian Framework allows: • effectively use your prior knowledge • take uncertainty in account • understand your data / problem better Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 29 / 29
  • 70. Take outs Bayesian Framework allows: • effectively use your prior knowledge • take uncertainty in account • understand your data / problem better BUT, you should really understand your problem Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 29 / 29
  • 71. Take outs Bayesian Framework allows: • effectively use your prior knowledge • take uncertainty in account • understand your data / problem better BUT, you should really understand your problem Tutorials/MISC: pymc3 docs: https://docs.pymc.io/nb_tutorials/index.html case studies: https://twiecki.io Max Kochurov PyMC3 – Bayesian Statistical Modelling in Python PyData – Moscow 29 / 29