Write a script which calculates sensitivity and specificity using functions.
Specificity - the fraction of those without the disease who get a negative test result.
These concepts can be represented as:
TP TN Sensitivity = ------- Specificity = ------- TP + FN TN + FP TP - true positive FP - false positive TN - true negative FN - false negativeThese categories can be represented like this in a simple table:
Disease Present | Disease Absent | |
Test Positive | TP | FP |
Test Negative | FN | TN |
A Perfect Test
In a perfect test there is a perfect correlation between those with the
disease and a positive test result and those who do not have the disease and
a negative test result. In a typical test there is a good deal of overlap
between these groups. A perfect test can be represented like this:
The dashed line represents the demarcation between positive and negative
test results. The experimenter sets this line and in the case of the perfect
test it is easy to decide where to place it. In the case of the typical
test, this decision is not so easy. Due to the overlap between the groups,
the placement of the line of demarcation has an impact on the diagnosis
rendered. Setting it further to the right increases the number of false
negatives (which means that more people with the disease may be considered
not to have the disease - this is not a good thing). Setting the line of
demarcation further to the left increase the number of false positives
(which means that more people without the disease will be told that they do
have the disease which could be psychologically traumatic for them, but
further testing should resolve this situation).
Functions in Python
A functions (aka, method or subroutine) is a separate body of code designed to perform a particular task. Functions are called or invoked from the main body of your script. The act of invoking a functions is sometimes called calling the function or a function call. Here's a quick example:
This program could have been written slightly differently like this:
ASSIGNMENT:
Write a script with the following functions: