I am using the following pymc3 model.
model.verbose = 0
with model:
# top-level prior
gamma = []
alpha = 1. / numberOfRatingLevels
for k in range(numberOfRatingLevels):
gamma_k = pm.Gamma("gamma_%i" % k, alpha=alpha, beta=rate)
gamma_k = gamma_k * concentration
gamma.append(gamma_k)
# each movie
for m in range(numberOfMovies):
# sample the Dirichlet by sampling from gammas and normalizing
theta_m = []
for k in range(0, numberOfRatingLevels):
theta_mk = pm.Gamma("theta_%i%i" % (m, k), alpha=gamma[k], beta=1.)
theta_m.append(theta_mk)
theta_m = theta_m / np.sum(theta_m)
# rating counts for the movie
ratingCounts = serviceans_cnt_lst[m]
# use a multinomial to achieve repeated categorical draws
phi_m = pm.Multinomial("phi_%i" % m, n=ratingCounts.sum(), p=theta_m, observed=ratingCounts)
step = pm.Metropolis()
trace = pm.sample(3000, step=step)
The sampling takes more than 2 hours. Can someone help me?