Hello,
I’m getting a bunch of errors that I have not been able to fix on the below regression model. I’ve commented out most of the model to figure out what is wrong. There are 99 unique departments and holidays happen 7% of the time.
I was getting chain failure errors, then I changed the department and holiday to the correct distributions. Now I’m getting this:
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 (2,).
Model code below:
p1 = np.array([0.0101, 0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101
,0.0101, 0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101
,0.0101, 0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101
,0.0101, 0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101
,0.0101, 0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101
,0.0101, 0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101
,0.0101, 0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101
,0.0101, 0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101
,0.0101, 0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101
,0.0101, 0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.0101,0.01021])p2 = np.array([.93, .07])
with pm.Model() as sales_model:
#define the priors alpha = pm.Normal('intercept', mu=0, sd = 20) beta_1 = pm.Categorical('dept', p = p1) beta_2 = pm.Bernoulli('IsHoliday_T', p= p2) #beta_3 = pm.Normal('Week', mu=0, sd = 10) #beta_4 = pm.Normal('Fuel_Prices', mu=0, sd = 10) #beta_5 = pm.Normal('Temperature', mu=0, sd = 10) #beta_6 = pm.Normal('Markdown1', mu=0, sd = 10) #beta_7 = pm.Normal('Markdown2', mu=0, sd = 10) #beta_8 = pm.Normal('Markdown4', mu=0, sd = 10) #beta_9 = pm.Normal('Markdown5', mu=0, sd = 10) #beta_10 = pm.Normal('CPI', mu=0, sd = 10) #beta_11 = pm.Normal('Unemployment', mu=0, sd = 10) s = pm.Uniform('sd', lower = 1, upper = 20) #define the likelihood mu = alpha + beta_1*X_train['Dept'] + beta_2*X_train['IsHoliday_True'] #+ beta_3*X_train['Week'] + beta_4*X_train['Fuel_Price_s'] + beta_5*X_train['Temperature_s'] + beta_6*X_train['MarkDown1_s'] + beta_7*X_train['MarkDown2_s'] + beta_8*X_train['MarkDown4_s'] +beta_9*X_train['MarkDown5_s'] + beta_10*X_train['CPI_s'] + beta_11*X_train['Unemployment_s'] y = pm.Normal('sales', mu = mu, sd = s, observed = Y_train) step = pm.NUTS() trace = pm.sample(draws=10000, step = step ,progressbar=True)