Thanks for the code and data @jordan.howell2. However, I still can’t reproduce your error . Your code runs fine (after adding an if __name__ == "__main__"
) across multiple cores using the pymc3’s master branch on my machine. I think that you must be running into an installation issue or maybe theano
finding another c compiler (and python headers) instead of the one you installed through conda.
I would try uninstalling theano, pymc3, pygpu and running:
conda install numpy scipy mkl-service libpython m2w64-toolchain
conda install theano pygpu
conda install pymc3
As a side note, my only change to your script was adding an if __name__ == "__main__":
before sampling:
with pm.Model() as sales_model:
# define the priors
mu_a = pm.Normal('mu_a', mu=0, sd=10)
sigma_a = pm.HalfCauchy('sigma_a', 5)
# mu_d = pm.Normal('mu_d', mu = 0, sd = 10)
# sigma_d = pm.HalfCauchy('sigma_d', 5)
alpha = pm.Normal('intercept', mu=mu_a, sd=sigma_a, shape=n_dept)
beta_2 = pm.Normal('IsHoliday_T', mu=0, sd=20)
beta_3 = pm.Normal('Week', mu=0, sd=20)
s = pm.HalfCauchy('sd', 5)
# define the likelihood
mu = alpha[dept_idx] + beta_2 * train['IsHoliday_True'].values + beta_3 * train['Week'].values
y = pm.StudentT('sales', nu=5, mu=mu, sd=s
, observed=train['Weekly_Sales'], shape=train['Weekly_Sales'].shape)
if __name__ == "__main__":
with sales_model:
trace = pm.sample(draws=5000, init='advi', progressbar=True)
print(sales_model.check_test_point())
trace_plot = pm.traceplot(trace[1000:], grid=True)
ppc = pm.plot_posterior(trace[1000:])
summary = pm.summary(trace)
posterior = pm.trace_to_dataframe(trace)