4
$\begingroup$

I am faced with this question:

$10$% of all email you receive is spam. Your spam filter is $90$% reliable, that is, $90$% of the mails it marks as spam are indeed spam and $90$% of spam mails are correctly labelled as spam. If you see a mail marked spam by your filter, what is the probability that it is really spam?

This question was posed in a Chennai Mathematical Institute exam. This is how I'm trying it.

$10$% of all email you receive is spam $$ P(\text{spam}) = 0.1 $$

$90$% of the mails it marks as spam are indeed spam $$ P(\text{spam|marked as spam}) = 0.9 $$

$90$% of spam mails are correctly labelled as spam $$ P(\text{marked as spam|spam}) = 0.9 $$

By Bayes' Theorem, we have $$ P(\text{spam|marked as spam}) = \frac{P(\text{marked as spam|spam}) P(\text{spam})}{P(\text{marked as spam})} $$ $$ 0.9 = \frac{0.9 * 0.1}{P(\text{marked as spam})} $$

Which is incorrect. I am not able to figure out what exactly I did wrong. The official solution goes like this

Out of 100 mails, 10 are spam. The filter will label 9 or 10 spam as spam and 9 of 90 non-spam as spam. So 18 are labelled spam, of which 9 are actually spam.

Can somebody show the right way to solve this using conditional probabilities?

$\endgroup$
5
$\begingroup$

There seems to be an error either in the question or your understanding of it. If the question indeed says

90% of the mails it marks as spam are indeed spam and 90% of spam mails are correctly labelled as spam,

this means \begin{equation} P(\textrm{spam} \mid \textrm{marked}) =0.9, P(\textrm{marked} \mid \textrm{spam}) = 0.9, \end{equation} and the question doesn't make much sense as the answer is stated directly in the question, while the official solution is wrong. However, I suspect the intended premises actually were something like

It marks 90 % of spam mails as spam, and 90 % of non-spam mails as not spam,

which translates to conditional probability statements as follows: \begin{equation} P(\textrm{marked} \mid \textrm{spam}) = 0.9, P(\neg\textrm{marked} \mid \neg \textrm{spam}) = 0.9. \end{equation}

In this case you can match the intended solution by using Bayes' theorem to compute \begin{equation} P(\textrm{spam} \mid \textrm{marked}) = \ldots = 0.5. \end{equation}

$\endgroup$
2
$\begingroup$

You say that '...90% of the mails marked is indeed spam'. That should probably be changed into '...90% of the mails that is spam is indeed marked'.

On base of$P\left[\text{spam}\right]=0.1$, $P\left[\text{marked}\mid\text{spam}\right]=0.9$ and $P\left[\text{marked}\mid\text{no spam}\right]=0.1$ we find:

$$P\left[\text{spam}\mid\text{marked}\right]=\frac{P\left[\text{spam}\wedge\text{marked}\right]}{P\left[\text{marked}\right]}=\frac{P\left[\text{marked}\mid\text{spam}\right]P\left[\text{spam}\right]}{P\left[\text{marked}\mid\text{spam}\right]P\left[\text{spam}\right]+P\left[\text{marked}\mid\text{no spam}\right]P\left[\text{no spam}\right]}=\frac{0.9\times0.1}{0.9\times0.1+0.1\times0.9}=\frac{1}{2}$$

$\endgroup$
  • $\begingroup$ Isn't that already given? '...90% of spam mails are correctly labelled as spam' $\endgroup$ – pranavashok Apr 23 '14 at 14:04
  • $\begingroup$ Yes, you are right. I think that the information that I mentioned as 'to be changed' should in fact be omitted. It provides an answer to the question that is posed, and moreover that answer does not equalize the answer that is found. A very confusing situation. This is also mentioned in the answer of Juho. $\endgroup$ – drhab Apr 23 '14 at 14:17
1
$\begingroup$

Why did you decide ${P(marked\ as\ spam)} = 0.1$ is incorrect?

In fact, this makes perfect sense..

Out of 100 mails, the classifier is expected to mark 10 as spam, 9 of which are actual spam and there's another spam mail which successfully bypassed the filter.


In your question you wrote

"and 9 of 90 non-spam as spam."

Which is not the expected case, as ${P(marked\ as\ spam | not\ spam)} \neq 0.1$.

$\endgroup$
  • $\begingroup$ I have written the question as well as the answer per-se. I have the same doubt as you as to how 9 out of 90 non-spam are marked as spam. I think the question is ambiguous, but I can't figure out how. $\endgroup$ – pranavashok Apr 23 '14 at 11:02

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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