Page 42 - Data Science Algorithms in a Week
P. 42

Naive Bayes


            Medical test - basic application of Bayes'

            theorem

            A patient takes a special cancer test which has the accuracy test_accuracy=99.9%: if the result
            is positive, then 99.9% of the patients tested will suffer from the special type of cancer.
            99.9% of the patients with a negative result do not suffer from the cancer.

            Suppose that a patient is tested and scores positive on the test. What is the probability that a
            patient suffers from the special type of cancer?

            Analysis:

            We will use Bayes' theorem to find out the probability of the patient having the cancer:

                         P(cancer|test_positive)=(P(test_positive|cancer) * P(cancer))/P(test_positive)

            To know the prior probability that a patient has the cancer, we have to find out how
            frequently the cancer occurs among people. Say that we find out that 1 person in 100,000
            suffers from this kind of cancer. Then P(cancer)=1/100,000. So, P(test_positive|cancer) =
            test_accuracy=99.9%=0.999 given by the accuracy of the test.

            P(test_positive) has to be computed:
            P(test_positive)=P(test_positive|cancer)*P(cancer)+P(test_positive|no_cancer)*P(no_cancer)

            = test_accuracy*P(cancer)+(1-test_accuracy)*(1-P(cancer))

            = 2*test_accuracy*P(cancer)+1-test_accuracy-P(cancer)
            Therefore, we can compute the following:

            P(cancer|test_positive) = (test_accuracy * P(cancer))/(2 * test_accuracy * P(cancer)+1-
            test_accuracy-P(cancer))

            = 0.999 * 0.00001 / (2 * 0.999 * 0.00001 + 1 - 0.999-0.00001)
            = 0.00989128497 which is approximately 1%












                                                     [ 30 ]
   37   38   39   40   41   42   43   44   45   46   47