2
$\begingroup$

I have, in some sense, an opposite question to Is it okay to use cross entropy loss function with soft labels? which is why is it ok NOT to use soft labels in classification?

Let's say you have a binary classification task you want to solve. Here's how you'd normally go about it. You start with some unknown probability distribution $u(y=1|x)$. You approximate $u(y=1|x)$ by sampling from it to generate a dataset (probability distribution $p(y=1|x)$). Then you create a model $q(y=1|x)$. You then fit the model to probability distribution $p(y=1|x)$ by minimizing cross entropy loss between $q(y=1|x)$ and $p(y=1|x)$.

To compute cross entropy it's commonly assumed that $p(y=1|x)$ is always 1 or 0 even though it's not necessarily true - for example imagine that in our dataset there are two patients with the same weight, height etc but one is ill and the other is not - if so $p(y=1|x) = 1/2$. In contrast, you'd normally set the 1st sample $p(y=1|x)$ as 0 and the 2nd one as 1. Why is it so extremely common to make this assumption? Is it a safe assumption and if so why? In other words why aren't soft labels ALWAYS used for classification tasks?

EDIT: additional clarification. If I have a finite dataset, the $p(y=1|x)$ is a finite probability distribution. I can use the cross entropy formula to measure $q(y=1|x)$ estimator error like so $$ CE(p, q) = \sum_{x \in X} p(y=1|x) log(q(y=1|x)) $$ Let's say my dataset consists of two feature-outcome vectors $(f_1, ... f_p, 0)$ and $(f_1, ..., f_p, 1)$. Then I compute cross entropy like this (I will abbreviate $p(y=1|x)$ as $p(x)$). $$ X = \{x_0\} = \{(f_1, ..., f_p)\} \\ p(x_0) = 0.5 \\ CE(p, q) = \sum_{x \in X} p(x)log(q(x)) = p(x_0)log(q(x_0)) = 0.5log(q(x_0)) $$ On the other hand, here's how people often talk about implementing cross entropy (example)

$$ X = \{x_0, x_1\}; \; x_0 = x_1 \\ p(x_0) = 0; \; p(x_1) = 1 \\ x_0 = x_1 \implies q(x_0) = q(x_1) \\ CE(p, q) = \frac{1}{|X|}\sum_{x \in X}p(x)log(q(x)) = \frac{1}{2}(0 \cdot log(q(x_0)) + 1 \cdot log(q(x_1))) = 0.5log(q(x_0)) $$ I have three problems with this:

  1. It is not mathematically sound to say that $p(x_0) = 0$ and $p(x_1) = 1$ because $x_0 = x_1 \implies p(x_0) = p(x_1)$
  2. In this case I ended up with the same number but I don't know if it's always the case.
  3. I don't know how to relate one definition to the other (this is very similar to this unanswered question
$\endgroup$
8
  • $\begingroup$ What do you mean that you have p(y=1|x) = 1/2 as an observation? When you look at the data, you have one feature-outcome vector of $(f_1, \dots, f_p, 0)$ and another of $(f_1, \dots, f_p, 1)$, agreed? $\endgroup$
    – Dave
    Commented Nov 26 at 11:13
  • $\begingroup$ @Dave I'm not sure what you mean by "p(y=1|x) = 1/2 as an observation". What I meant to say is I have two observations (samples) from which I can deduct that p(y=1|x) = 1/2. These observations are $(f_1, ..., f_p, 0)$ and $(f_1, ..., f_p, 1)$ exactly like you said. $\endgroup$
    – YuseqYaseq
    Commented Nov 26 at 11:25
  • $\begingroup$ So use the observed labels of 0 and 1. What's the problem? $\endgroup$
    – Dave
    Commented Nov 26 at 11:25
  • $\begingroup$ @Dave I added additional clarification and an example. $\endgroup$
    – YuseqYaseq
    Commented Nov 26 at 12:44
  • $\begingroup$ Could you please explain problem #1 of your edit? From my perspective, the statistical or probabilistic formulation is to say that, given a particular feature vector, one Bernoulli-distrubuted random variable equals 0 while another equals 1. It is totally routine for $iid$ random variables to wind up taking different values. (This is why sample spaces can have more than one point.) $\endgroup$
    – Dave
    Commented Nov 26 at 12:44

1 Answer 1

1
$\begingroup$

To compute cross entropy it's commonly assumed that p(y=1|x) is always 1 or 0

FALSE

Cross-entropy minimization coincides with maximum likelihood estimation when we assume a Bernoulli outcome, that is, a sample space of $\{0, 1\}$. However, the Bernoulli parameter being estimated by the regression can be any value on $[0, 1]$. That is, you use the 0,1 hard labels that are the observations in order to estimate the proportion. In your case, yes, you would get that the estimated proportion of outcomes, given that particular combination of features, is 50:50.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.