Predicting rare things is hardΒΆ
1 | import numpy as np |
1 | schiz_incidence = 16.3 / 100000 |
Incidence of schizophrenia 0.000163
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | specificity = .999 sensitivity = .999 n_screened = 1000000 print(f"Incidence of schizophrenia {schiz_incidence:.04}") print(f"Specificity: {specificity:.04}") print(f"Sensitivity: {sensitivity:.04}") # True positives tp = n_screened * schiz_incidence * sensitivity # False negatives fn = n_screened * schiz_incidence - tp # True negatives tn = n_screened * (1 - schiz_incidence) * specificity # False positives fp = n_screened * (1 - schiz_incidence) - tn print(f"True positives: {tp:.0f}") print(f"False positives: {fp:.0f}") print(f"True negatives: {tn:.0f}") print(f"False negatives: {fn:.0f}") # Positive predictive value ppv = tp / (tp + fp) print(f"Positive predictive value: {ppv:.04}") |
Incidence of schizophrenia 0.000163 Specificity: 0.999 Sensitivity: 0.999 True positives: 163 False positives: 1000 True negatives: 998837 False negatives: 0 Positive predictive value: 0.1401
1 |