Can anyone give some general instructions on how to parallelize PyMC MCMC code. I am trying to run a LASSO regression, following the example here . I read somewhere that parallel fetching is done by default, but do I still need to use something like Parallel Python to make it work?
Here is some reference code that I would like to parallelize on my machine.
x1 = norm.rvs(0, 1, size=n) x2 = -x1 + norm.rvs(0, 10**-3, size=n) x3 = norm.rvs(0, 1, size=n) X = np.column_stack([x1, x2, x3]) y = 10 * x1 + 10 * x2 + 0.1 * x3 beta1_lasso = pymc.Laplace('beta1', mu=0, tau=1.0 / b) beta2_lasso = pymc.Laplace('beta2', mu=0, tau=1.0 / b) beta3_lasso = pymc.Laplace('beta3', mu=0, tau=1.0 / b) @pymc.deterministic def y_hat_lasso(beta1=beta1_lasso, beta2=beta2_lasso, beta3=beta3_lasso, x1=x1, x2=x2, x3=x3): return beta1 * x1 + beta2 * x2 + beta3 * x3 Y_lasso = pymc.Normal('Y', mu=y_hat_lasso, tau=1.0, value=y, observed=True) lasso_model = pymc.Model([Y_lasso, beta1_lasso, beta2_lasso, beta3_lasso]) lasso_MCMC = pymc.MCMC(lasso_model) lasso_MCMC.sample(20000,5000,2)
python parallel-processing pymc pymc3
cmlakhan
source share