# Evaluating posterior predictive for classifying new data

Hi,

I have seen similar questions asked here and in Stack Exchange, and I think I checked out most of the tutorials, however I still don’t get how to make predictions for new data as in a supervised classification problem.

Examples use sample_posterior_predictive or sample_ppc, but these generate samples from the posterior predictive distribution, isn’t it right? As far as I understand, we need to evaluate the posterior predictive with the estimated parameters and new data (feature vector).

In Bishop’s PRML, the predictive distribution for logistic regression is given as follows:

p(C_1|\phi, \mathbf{t}) = \int p(C_1| \phi, \mathbf{w}) p(\mathbf{w} | \mathbf{t}) d\mathbf{w}

where \phi is the new feature vector, \mathbf{t} is the training labels, and \mathbf{w} is the estimated parameters.

So, instead of sampling this distribution, shouldn’t we evaluate p(t = C_1|\phi, \mathbf{t}) and p(t = C_2|\phi, \mathbf{t})?

A simple explanation for dummies (like me) or a simple classification example that someone could forward me to would be very helpful.

Thank you.

You can manually apply the posterior estimates of the beta coefficients to your new data and compare the output to your labels.

For instance:

test_x = [0, 1, 2, 3]
test_y = [0, 0, 1, 1]
test_y_pred = sigmoid(trace['beta0'] + trace['beta] * test_x)
np.mean( (test_y_pred > 0.5) == test_y) # PPC for new data
1 Like