12
$\begingroup$

Binary Probability distribution

The above is a very simple example of having a probability classifier output for a binary-class case either 0 or 1 based on some probabilities.
In addition it is straightforward how you can change the threshold. You set the threshold either higher or lower of 50% to change the precision/recall balance and thus optimize for your own unique situation.

However when we try to have the same thinking for a multiclass scenario, even as little as three classes as is shown in the picture below (imagine that these are probabilities)

Three Prob Dist

How do you begin to think how to shift the threshold?
The default is to take the class with the largest probability (here is class 3).
If you want to take this balance (to affect precision/recall) what could you do?
One idea could be to take the first most dominant classes re-normalize them and consider putting a threshold among these two, but this does not sound like an elegant solution.
Is there a solid methodology to follow?

$\endgroup$
0

1 Answer 1

12
$\begingroup$

You can use a prior distribution over the classes.

Let us assume that your model computes a vector of class probabilities $v$. You can define a vector of prior probabilities $\pi$ and then compute your class probabilities to be proportional to $v \circ \pi$, where $\circ$ denotes an element-wise product. So the probability that your observation belongs to class $c$ is proportional to $v_c\pi_c$.

If you want a proper distribution you just need to renormalize.

In your example, if you want your predictions to be slightly biased to class 1, you can define $\pi=(0.4, 0.3, 0.3)$, for instance.

If you think about it, in the binary case this is what you are implicitly doing this when you change the threshold. Let us say you establish the following rule: if your probability vector is $v$ and your decision function is $f(x)$, then $$ f(x)= \begin{cases} 2 & v_2\geq \theta \\ 1 & \mbox{otherwise} \end{cases} $$ for some $\theta \in (0,1)$.

Then this is equivalent (at least when it comes to making the decision) to computing the class probabilities to be proportional to $(\frac{v_1}{1-\theta}, \frac{v_2}{\theta})$, so you would be defining $\pi=(\frac{1}{1-\theta}, \frac{1}{\theta})$.

You can also learn the value of $\pi$ from your data. For instance, you can compute the proportion of each class and use that as prior probabilities.

For a more principled way of incorporating this kind of prior assumptions into your model, you might want to look at Bayesian inference.

$\endgroup$
3
  • $\begingroup$ Thanks for your answer. This makes sense. So you are suggesting after doing the element-wise multiplication with the priors to then just pick the largest number as you would normally do $\endgroup$ Commented Oct 31, 2017 at 11:18
  • $\begingroup$ Yes. Notice that if you renormalize the resulting vector, you will get a distribution with the same ordering. $\endgroup$
    – cangrejo
    Commented Oct 31, 2017 at 12:33
  • 1
    $\begingroup$ That is just beautiful, thaks! $\endgroup$
    – kkonevets
    Commented Oct 11, 2018 at 5:51

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