How to interpret the probability of classes in binary classification?

Hello Shaun!

In short, “class ‘1’” means whatever you trained you model for it
to mean.

To explain this, let me go back to one of your earlier posts:

You talk about x_test and y_test (and y_pred). I assume
that y_test is a vector of length the number of test samples,
with each value in y_test being the number 0, meaning that
this sample is in class “0”, or the number 1, meaning class “1”.
(And x_test is the input data whose classes you are trying
to predict.)

You don’t mention it, but I assume you also have an x_train
and y_train whose meanings are analogous, and that you
used x_train and y_train to train your network. The point
is that the meaning of the output of your model (whether a
given value for y_pred = classifier(x_test) means
class “0” or class “1”) depends on how you trained your model.

If you train your model with values of y_train of 1 indicating
class “1” (and feed it into BCEWithLogitsLoss) then larger
(more positive) values of y_pred will mean that you are
predicting class “1” to be more likely and smaller (more negative)
values of y_pred predict class “0” to be more likely (and
class “1” to be less likely), with the predicted probability of
class “'1” given by the sigmoid of y_pred, as discussed in
the earlier posts.

To summarize, the meaning of y_pred depends in a
straightforward way on the meaning of the y_train that you
used to train your classifier.

Best.

K. Frank

1 Like