Skip to content

Commit bae7f98

Browse files
🎨 Update plots from pymc to arviz dependencies & replace param sd with sigma
1 parent 0975dfb commit bae7f98

File tree

9 files changed

+19
-15
lines changed

9 files changed

+19
-15
lines changed

examples/case_studies/disaster_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
"""
1010

11-
11+
import arviz as az
1212
import theano.tensor as tt
1313

1414
from numpy import arange, array
@@ -152,4 +152,4 @@
152152
start = {"early_mean": 2.0, "late_mean": 3.0}
153153

154154
tr = pm.sample(1000, tune=500, start=start)
155-
pm.traceplot(tr)
155+
pm.plot_trace(tr)

examples/case_studies/disaster_model_theano_op.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Note that gradient based samplers will not work.
55
"""
66

7-
7+
import arviz as az
88
import theano.tensor as tt
99

1010
from numpy import arange, array, empty
@@ -166,4 +166,4 @@ def rate_(switchpoint, early_mean, late_mean):
166166
start = {"early_mean": 2.0, "late_mean": 3.0}
167167

168168
tr = pm.sample(1000, tune=500, start=start, step=[step1, step2], cores=2)
169-
pm.traceplot(tr)
169+
az.plot_trace(tr)

examples/case_studies/garch_example.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import numpy as np
22
import theano.tensor as tt
33

4-
from pymc3 import Model, Normal, Uniform, sample, summary
4+
from arviz import summary
5+
from pymc3 import Model, Normal, Uniform, sample
56

67
"""
78
Example from Stan - slightly altered

examples/case_studies/gelman_schools.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import numpy as np
22

3-
from pymc3 import HalfCauchy, Model, Normal, loo, sample
3+
from arviz import loo
4+
from pymc3 import HalfCauchy, Model, Normal, sample
45

56
"""Original Stan model
67

examples/case_studies/lightspeed_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import numpy as np
2-
2+
import arviz as az
33
import pymc3 as pm
44

55
light_speed = np.array(
@@ -92,7 +92,7 @@ def run(n=5000):
9292
with model_1:
9393
trace = pm.sample(n)
9494

95-
pm.summary(trace)
95+
az.summary(trace)
9696

9797

9898
if __name__ == "__main__":

examples/pymc3_howto/LKJ_correlation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import numpy as np
22
import theano.tensor as tt
3-
3+
import arviz as az
44
from numpy.random import multivariate_normal
55

66
import pymc3 as pm
@@ -53,7 +53,7 @@ def run(n=1000):
5353
n = 50
5454
with model:
5555
trace = pm.sample(n)
56-
pm.traceplot(
56+
az.plot_trace(
5757
trace, varnames=["mu", "r"], lines={"mu": mu_r, "r": corr_r[np.triu_indices(n_var, k=1)]}
5858
)
5959

examples/pymc3_howto/rankdata_ordered.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ def run(n=1500):
4646
with m:
4747
trace = pm.sample(n)
4848

49-
pm.traceplot(trace, varnames=["mu_hat"])
49+
az.plot_trace(trace, varnames=["mu_hat"])
5050

5151
print("Example observed data: ")
5252
print(y[:30, :].T)
5353
print("The true ranking is: ")
5454
print(yreal.flatten())
5555
print("The Latent mean is: ")
56-
latentmu = np.hstack(([0], pm.summary(trace, varnames=["mu_hat"])["mean"].values))
56+
latentmu = np.hstack(([0], az.summary(trace, varnames=["mu_hat"])["mean"].values))
5757
print(np.round(latentmu, 2))
5858
print("The estimated ranking is: ")
5959
print(np.argsort(latentmu))

examples/samplers/samplers_mvnormal.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import time
1111

12+
import arviz as az
1213
import numpy as np
1314
import pandas as pd
1415
import theano.tensor as tt
@@ -50,7 +51,7 @@ def run(steppers, p):
5051
runtimes[name] = time.time() - t_start
5152
print("{} samples across {} chains".format(len(mt) * mt.nchains, mt.nchains))
5253
traces[name] = mt
53-
en = pm.ess(mt)
54+
en = az.ess(mt)
5455
print(f"effective: {en}\r\n")
5556
if USE_XY:
5657
effn[name] = np.mean(en["x"]) / len(mt) / mt.nchains

examples/time_series/arma_example.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from theano import scan, shared
44

5+
import arviz as az
56
import pymc3 as pm
67

78
"""
@@ -82,8 +83,8 @@ def run(n_samples=1000):
8283
with model:
8384
trace = pm.sample(draws=n_samples, tune=1000, target_accept=0.99)
8485

85-
pm.plots.traceplot(trace)
86-
pm.plots.forestplot(trace)
86+
az.plot_trace(trace)
87+
az.plot_forest(trace)
8788

8889

8990
if __name__ == "__main__":

0 commit comments

Comments
 (0)