Hello,
I’m having issues passing OOS data to a model for sampling. I’m using the following code snippet to pass OOS data:
t_test = np.arange(1, 1+12/T, 1/T) #add one to time steps
test_x_fourier = create_fourier_features(t_test, n=5, p=12/T)
with constant_model:
test_item_idx = np.array(list(map(item_to_idx_dict.get, df_test.index.get_level_values(1))))
test_time_idx, _ = pd.factorize(df_test.index.get_level_values(0))
test_price_idx = df_test['price_group'].astype('int')-1
test_promo_idx_, _ = pd.factorize(df_test['PROMO_FLG'].astype('int'))
pm.set_data({'item_idx':test_item_idx,
'time_idx':test_time_idx,
'price_groups':test_price_idx,
'log_eaches':df_test.DMAND_QTY.apply(np.log).values,
't': t_test,
'x_fourier':test_x_fourier,
'promo':test_promo_idx})
test_ppc = pm.sample_posterior_predictive(idata)
However, I’m all of the sudden (this worked a week ago), getting the following error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/tmp/ipykernel_129069/20214747.py in <module>
15 't': t_test,
16 'x_fourier':test_x_fourier,
---> 17 'promo':test_promo_idx})
18
19 test_ppc = pm.sample_posterior_predictive(idata)
/opt/conda/lib/python3.7/site-packages/pymc/model.py in set_data(new_data, model, coords)
1873
1874 for variable_name, new_value in new_data.items():
-> 1875 model.set_data(variable_name, new_value, coords=coords)
1876
1877
/opt/conda/lib/python3.7/site-packages/pymc/model.py in set_data(self, name, values, coords)
1227 if isinstance(values, list):
1228 values = np.array(values)
-> 1229 values = convert_observed_data(values)
1230 dims = self.RV_dims.get(name, None) or ()
1231 coords = coords or {}
/opt/conda/lib/python3.7/site-packages/pymc/aesaraf.py in convert_observed_data(data)
116 else:
117 # already a ndarray, but not masked
--> 118 mask = np.isnan(data)
119 if np.any(mask):
120 ret = np.ma.MaskedArray(data, mask)
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
I’ve checked my data and there is no nan
values in it. The dtypes of the data match the dtypes of the data the model was fit on. Has anyone else seen this?