Hi,
I am trying to estimate the parameters of a joint distribution. I have a vector of values for each feature. A simplified version of the problem, giving the same error is:
num_shifts=24
num_lenghts=24
num_dow=7
data = {‘P_SD’:shift, ‘P_ED’:end_hour, ‘P_length’:lengths, ‘P_dow’:dow, ‘P_hr’:hrs}
#Each value in the previous dictionary is a 1D np.arraywith pm.Model() as model:
sd1 = pm.Uniform('sd_SD', 0.25, 5, shape=num_shifts) lambdas1 = pm.Uniform('lambdas_SD', 0, 1.0, shape=num_shifts) p_sd = pm.NormalMixture('P_SD', mu=np.arange(num_shifts), w=lambdas1, sd=sd1) sd2 = pm.Uniform('sd_ED', 0.25, 5, shape=num_shifts) lambdas2 = pm.Uniform('lambdas_ED', 0, 1.0, shape=num_shifts) p_ed = pm.NormalMixture('P_ED', mu=np.arange(num_shifts), w=lambdas2, sd=sd2) sd3 = pm.Uniform('sd_L', 0.25, 5, shape=num_lenghts) lambdas3 = pm.Uniform('lambdas_L', 0, 1.0, shape=num_lenghts) p_length = pm.NormalMixture('P_length', mu=np.arange(num_lenghts), w=lambdas3, sd=sd3) prior_dow = pm.Dirichlet('prior_dow', a=pm.floatX((1.0 / num_dow) * np.ones(num_dow))) p_dow = pm.Multinomial('P_dow',num_dow, prior_dow) mean_hr = pm.Uniform("mh", 50, 110) std_hr = pm.Uniform("sh", 1, 30) p_hr = pm.Normal('P_hr',mean_hr, std_hr) pm.Potential('mylike', p_sd * p_ed * p_length * p_dow * p_hr, observed=data) step = pm.NUTS() trace = pm.sample(20000, step=step) burned_trace = trace[10000:]
The error I’m getting is:
TypeError: For compute_test_value, one input test value does not have the requested type.
The error when converting the test value to that variable type:
Wrong number of dimensions: expected 0, got 1 with shape (7,).
The error happens in p_dow = pm.Multinomial(‘P_dow’,num_dow, prior_dow). Any ideas?
Thanks