Out of sample prediction with new category

Another way you can try is adding new nodes to existing model that you already done the inference, and run posterior predictive sample using the new variables, which in this case:

with varying_intercept:
    a_county_new = pm.Normal("a_county_new", mu=a, sigma=sigma_a)
    theta_new = a_county_new+ b * floor_idx_new

    y_new = pm.Normal("y_new", theta_new, sigma=sigma)
    ppc = pm.sample_posterior_predictive(trace, var_names=['y_new'])

ppc.posterior_predictive['y_new']
4 Likes