# How the probability threshold of a classifier can be adjusted in case of multiple classes?

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)

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?

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.

• 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 – George Pligoropoulos Oct 31 '17 at 11:18
• Yes. Notice that if you renormalize the resulting vector, you will get a distribution with the same ordering. – cangrejo Oct 31 '17 at 12:33
• That is just beautiful, thaks! – guyos Oct 11 '18 at 5:51