Combining two probablities based on context

50 Views Asked by At

I have written an object detection algorithm which can localize different classes on a given image. For each class, the output is given as a list of bounding boxes around each detected class along with probability and class label.

The object detection algorithm doesn't know about the context of the classes, e.g. that object A is very likely to appear when object B is present or nearby.

Let's say that the detector found object A with a certainty of 80% and object B with a certainty of 85%. I also know the likelihood that object A is present if object B is present is 0.9.

Now with this information, couldn't I derive that the likelihood that object A ist present increases to, say, 82%?

If so, how would that look like mathematically? I've been pondering about that for a while now and I've considered Bayes rule, but I can't really make it fit my specific problem.

Thanks.

1

There are 1 best solutions below

2
On

You don't have enough information to draw that conclusion. You only have $P(A\mid B)=0.9$ but not $P(A\mid\neg B)$. For all we know, we could have $P(A\mid\neg B)=0$ or $P(A\mid\neg B)=1$; in the first case, the presence of $B$ would raise the probability of $A$ being present, whereas in the second case it would decrease that probability. That "object $A$ is very likely to appear when object $B$ is present" doesn't preclude the possibility that it's even more likely to appear when object $B$ isn't present, and hence in fact less likely to appear when object $B$ is present than if we have no information about the presence of $B$.

You also don't know whether the conditional probability of $85\%$ for $B$ to be present given that the detector indicates $85\%$ for $B$ is higher or lower than the unconditional probability for $B$ to be present. Again, if the unconditional probability for $B$ to be present were $95\%$, the information from the indicator would actually lower the probability of $B$ to be present, and thus even if we had $P(A\mid B)\gt P(A)$, the detector indicating $85\%$ for $B$ could still lower the probability for $A$ to be present.

I suspect that these cases probably seem pathological in your context, as the conditional probabilities you specify are probably higher than the unconditional probabilities you don't specify – the point is not so much that these extreme cases would actually occur in practice, but to point out that the result you want depends on these unconditional probabilities, and even though the sign of the effect is probably the one you expect, its magnitude can't be calculated without further information.

Edit in response to the comment:

Assume you know $P(A)$ and $P(B)$. I interpret the data in your post to mean $P(A\mid B)=0.9$, $P(A\mid A_{80})=0.8$ and $P(B\mid B_{85})=0.85$, where $A_{80}$ is the event that the detector indicates an $80\%$ probability for $A$ and $B_{85}$ is the event that the detector indicates an $85\%$ probability for $B$. I also assume that "The object detection algorithm doesn't know about the context of the classes" implies $P(A_{80}\mid AB)=P(A_{80}\mid A\overline B)=P(A_{80}\mid A)$ and $P(B_{85}\mid BA)=P(B_{85}\mid B\overline A)=P(B_{85}\mid B)$ as well as $P(A_{80}B_{85}\mid AB)=P(A_{80}\mid A)P(B_{85}\mid B)$ (and likewise for $A\overline B$, $\overline AB$ and $\overline A\overline B$); that is, whether the detector indicates $A_{80}$ or $B_{85}$ depends only on the presence of $A$ or $B$, respectively, and not on the presence of the other object or on the other detection event.

Since you have $P(A)$, $P(B)$ and $P(A\mid B)$, you can obtain $P(AB)=P(A\mid B)P(B)$ and all other probabilities involving only $A$ and $B$ and not the detection events. For succinctness, let $S=\{AB,A\overline B,\overline AB,\overline A\overline B\}$ be the set of pairs of the object presence events and their complements, and for $E\in S$ let $E_A$ denote the first part of $E$ ($A$ or $\overline A$) and $E_B$ the second part ($B$ or $\overline B$).

Now you want to determine $P(A\mid A_{80}B_{85})$. This is

\begin{eqnarray*} P(A\mid A_{80}B_{85}) &=& \frac{P(AA_{80}B_{85})}{P(A_{80}B_{85})} \\ &=& \frac{P(AA_{80}B_{85}B)+P(AA_{80}B_{85}\overline B)}{\sum_{E\in S}P(A_{80}B_{85}E)} \\ &=& \frac{P(A_{80}B_{85}\mid AB)P(AB)+P(A_{80}B_{85}\mid A\overline B)P(A\overline B)}{\sum_{E\in S}P(A_{80}B_{85}\mid E)P(E)} \\ &=& \frac{P(A_{80}\mid A)P(B_{85}\mid B)P(AB)+P(A_{80}\mid A)P(B_{85}\mid\overline B)P(A\overline B)}{\sum_{E\in S}P(A_{80}\mid E_A)P(B_{85}\mid E_B)P(E)}\;. \end{eqnarray*}

Now note that e.g.

$$P(A_{80}\mid A)=\frac{P(A_{80}A)}{P(A)}=\frac{P(A_{80})}{P(A)}{P(A\mid A_{80})}\;.$$

If we apply this for all the unknown conditional probabilities of the form $P(A_{80}\mid A)$ we get a factor of $P(A_{80})$ and a factor of $P(B_{85})$ in every term, so these unknown probabilities cancel and we're left only with known quantities:

$$ P(A\mid A_{80}B_{85})=\frac{P(A\mid A_{80})P(B\mid B_{85})P(AB)/(P(A)P(B))+P(A\mid A_{80})P(\overline B\mid B_{85})P(A\overline B)/(P(A)P(\overline B))}{\sum_{E\in S}P(E_A\mid A_{80})P(E_B\mid B_{85})P(E)/(P(E_A)P(E_B))}\;. $$

Note: I make no claim that this can't be done more elegantly and simply; this is just what I came up with how to do it :-)