bayesplain.teach.NaturalFrequencies¶
-
class bayesplain.teach.NaturalFrequencies(table, n, base_rate, sensitivity, specificity, case_label=
'cases', condition_label='the condition', flag_label='flagged')[source]¶ A 2x2 grid of whole counts, and what it implies.
- Variables:¶
- table¶
[[true positive, false negative], [false positive, true negative]]as integers.- n¶
Total number of imagined cases.
- base_rate¶
The prevalence that was assumed.
- sensitivity¶
The detection rate that was assumed.
- specificity¶
The correct-clearance rate that was assumed.
- case_label=
'cases'¶ What one row of the imagined data is.
- condition_label=
'the condition'¶ The thing being detected.
- flag_label=
'flagged'¶ What the detector does when it fires.
Methods
Compute the same answer from the formula, for comparison.
summary()Print the grid and read the answer off it.
- bayes_rule_check()[source]¶
Compute the same answer from the formula, for comparison.
- Returns:¶
P(condition | flag)by Bayes’ rule. Agrees withposterior_given_flagup to the rounding needed to keep the grid in whole numbers, which is the point: the counting and the formula are the same operation.- Return type:¶
- property posterior_given_flag[source]¶
Share of flagged cases that actually have the condition.
This is the number the exercise is about, and it is obtained by dividing one count by another – no formula required.