|
5 | 5 | import matplotlib.pyplot as plt
|
6 | 6 |
|
7 | 7 |
|
| 8 | +@figure |
| 9 | +def plot_probability_inconsistent(set_2_alpha, set_1_alpha, set_3_alpha, comp_set_1_alpha, n_fits): |
| 10 | + """ |
| 11 | + P(inconsistent) = P(set 2 | set 1) + P(set 3) + P(set 2 | ~ set 1) |
| 12 | + """ |
| 13 | + |
| 14 | + fig, ax = plt.subplots() |
| 15 | + |
| 16 | + tagged_rates = [] |
| 17 | + for alpha in set_2_alpha.keys(): |
| 18 | + set_2_inters_1 = set_2_alpha[alpha].intersection(set_1_alpha[alpha]) |
| 19 | + set_3 = set_3_alpha[alpha] |
| 20 | + set_2_inters_comp_1 = set_2_alpha[alpha].intersection(comp_set_1_alpha[alpha]) |
| 21 | + |
| 22 | + set_tagged_fits = set_2_inters_1.union(set_3).union(set_2_inters_comp_1) |
| 23 | + tagged_rates.append(len(set_tagged_fits) / n_fits) |
| 24 | + |
| 25 | + ax.plot(set_2_alpha.keys(), tagged_rates, label="P(inconsistent)") |
| 26 | + ax.legend() |
| 27 | + return fig |
| 28 | + |
| 29 | +@figure |
| 30 | +def plot_probability_consistent(set_2_alpha, set_1_alpha, set_3_alpha, comp_set_1_alpha, comp_set_2_alpha, comp_set_3_alpha, n_fits): |
| 31 | + """ |
| 32 | + P(consistent) = 1 - P(inconsistent) ?= P(~set 2 | ~set 1) + P(~set 2 and ~set 3| set 1) |
| 33 | + """ |
| 34 | + fig, ax = plt.subplots() |
| 35 | + |
| 36 | + untagged_rates = [] |
| 37 | + untagged_rates_method2 = [] |
| 38 | + for alpha in set_2_alpha.keys(): |
| 39 | + set_2_inters_1 = set_2_alpha[alpha].intersection(set_1_alpha[alpha]) |
| 40 | + set_3 = set_3_alpha[alpha] |
| 41 | + set_2_inters_comp_1 = set_2_alpha[alpha].intersection(comp_set_1_alpha[alpha]) |
| 42 | + |
| 43 | + comp_set_2_inters_comp_set1 = comp_set_2_alpha[alpha].intersection(comp_set_1_alpha[alpha]) |
| 44 | + comp_set_2_inters_comp_set3 = comp_set_2_alpha[alpha].intersection(comp_set_3_alpha[alpha]) |
| 45 | + comp_set_2_inters_comp_set3_inter_set_1 = comp_set_2_inters_comp_set3.intersection(set_1_alpha[alpha]) |
| 46 | + |
| 47 | + set_untagged_fits = comp_set_2_inters_comp_set1.union(comp_set_2_inters_comp_set3_inter_set_1) |
| 48 | + |
| 49 | + |
| 50 | + set_tagged_fits = set_2_inters_1.union(set_3).union(set_2_inters_comp_1) |
| 51 | + untagged_rates.append(1 - len(set_tagged_fits) / n_fits) |
| 52 | + |
| 53 | + untagged_rates_method2.append(len(set_untagged_fits) / n_fits) |
| 54 | + |
| 55 | + |
| 56 | + ax.plot(set_2_alpha.keys(), untagged_rates, label="1 - P(inconsistent)") |
| 57 | + ax.plot(set_2_alpha.keys(), untagged_rates_method2, label="P(~set 2 | ~set 1) + P(~set 2 and ~set 3| set 1)") |
| 58 | + ax.legend() |
| 59 | + |
| 60 | + return fig |
| 61 | + |
| 62 | + |
| 63 | + |
8 | 64 | @figure
|
9 | 65 | def plot_set1_vs_set3_alpha(set_1_alpha, set_3_alpha, weighted_dataset, n_fits):
|
10 | 66 | """
|
|
0 commit comments