Package author @fonnesbeck informed me that I needed the development version 3 from Github and not the pypi version 2.3. Installed that, via github and I'm good to go. Open source is great!
Getting started with PYMC for linear regression
Question
Thought I'd start off following this example: http://www.databozo.com/2014/01/17/Exploring_PyMC3.html
But when I follow the example precisely using pymc 2.3 I get an exit and told that the API has changed UserWarning: The MCMC() syntax is deprecated. Please pass in nodes explicitly via M = MCMC(input). 'The MCMC() syntax is deprecated. Please pass in nodes explicitly via M = MCMC(input).') but I don't have a good idea how to change the example to provide exactly what to the model function and how to do with the 'with' clause?
The code in question is:
%pylab inline
import scipy
import numpy as np
x = np.array(range(0,50))
y = np.random.uniform(low=0.0, high=40.0, size=200)
y = map((lambda a: a[0] + a[1]), zip(x,y))
import matplotlib.pyplot as plt
plt.scatter(x,y)
Above sample data generator works fine
import pymc as pm
import numpy as np
trace = None
with pm.Model() as model: <<<<<<indicated as the error line
alpha = pm.Normal('alpha', mu=0, sd=20)
beta = pm.Normal('beta', mu=0, sd=20)
sigma = pm.Uniform('sigma', lower=0, upper=20)
y_est = alpha + beta * x
likelihood = pm.Normal('y', mu=y_est, sd=sigma, observed=y)
start = pm.find_MAP()
step = pm.NUTS(state=start)
trace = pm.sample(2000, step, start=start, progressbar=False)
pm.traceplot(trace);
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow