Skip to content

Commit 0e54ce6

Browse files
author
Junpeng Lao
authored
Merge pull request #2250 from junpenglao/bugfix#2247
Fix issue #2247
2 parents 6f58dbf + e6dfd2e commit 0e54ce6

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

pymc3/examples/lasso_missing.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,21 @@
1414
'mother_hs', 'early_ident']].astype(float).values.T
1515

1616
with pm.Model() as model:
17-
1817
# Impute missing values
19-
sib_mean = pm.Exponential('sib_mean', 1)
18+
sib_mean = pm.Exponential('sib_mean', 1.)
2019
siblings_imp = pm.Poisson('siblings_imp', sib_mean,
2120
observed=masked_values(siblings, value=-999))
2221

23-
p_disab = pm.Beta('p_disab', 1, 1)
22+
p_disab = pm.Beta('p_disab', 1., 1.)
2423
disability_imp = pm.Bernoulli(
2524
'disability_imp', p_disab, observed=masked_values(disability, value=-999))
2625

27-
p_mother = pm.Beta('p_mother', 1, 1)
26+
p_mother = pm.Beta('p_mother', 1., 1.)
2827
mother_imp = pm.Bernoulli('mother_imp', p_mother,
2928
observed=masked_values(mother_hs, value=-999))
3029

31-
s = pm.HalfCauchy('s', 5, testval=5)
32-
beta = pm.Laplace('beta', 0, 100, shape=7, testval=.1)
30+
s = pm.HalfCauchy('s', 5., testval=5)
31+
beta = pm.Laplace('beta', 0., 100., shape=7, testval=.1)
3332

3433
expected_score = (beta[0] + beta[1] * male + beta[2] * siblings_imp + beta[3] * disability_imp +
3534
beta[4] * age + beta[5] * mother_imp + beta[6] * early_ident)
@@ -41,7 +40,6 @@
4140
with model:
4241
start = pm.find_MAP()
4342
step1 = pm.NUTS([beta, s, p_disab, p_mother, sib_mean], scaling=start)
44-
4543
step2 = pm.Metropolis([mother_imp.missing_values,
4644
disability_imp.missing_values,
4745
siblings_imp.missing_values])
@@ -51,7 +49,7 @@ def run(n=5000):
5149
if n == 'short':
5250
n = 100
5351
with model:
54-
pm.sample(n, [step1, step2], start)
52+
pm.sample(n, step=[step1, step2], start=start)
5553

5654

5755
if __name__ == '__main__':

0 commit comments

Comments
 (0)