-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_paper_figures.py
91 lines (65 loc) · 3.02 KB
/
create_paper_figures.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import os
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from scipy.stats import norm
sns.set_theme(context="poster", style="darkgrid")
sns.set_context("poster")
"""Continuous PDF figure"""
mu = 0.5
sigma1 = 0.25
sigma2 = 0.1
fth = 0.6
norm_dist1 = norm(loc=mu, scale=sigma1)
norm_dist2 = norm(loc=mu, scale=sigma2)
x = np.linspace(0, 1, 100)
y1 = norm_dist1.pdf(x)
y2 = norm_dist2.pdf(x)
df1 = pd.DataFrame({"x": x, "y": y1, "variance": [sigma1 for _ in range(len(x))]})
df2 = pd.DataFrame({"x": x, "y": y2, "variance": [sigma2 for _ in range(len(x))]})
ax = sns.lineplot(
pd.concat([df1, df2], ignore_index=True), x="x", y="y", hue="variance", palette=["royalblue", "orange"]
)
ax.fill_between(np.linspace(fth, 1, 100), norm_dist2.pdf(np.linspace(fth, 1, 100)), color="blue", alpha=0.3)
ax.fill_between(np.linspace(fth, 1, 100), norm_dist1.pdf(np.linspace(fth, 1, 100)), color="orange", alpha=0.3)
plt.plot((mu, mu), (0.0, norm_dist2.pdf(mu)), color="black", linestyle="dashed")
ax.set_xlabel("$F(\mathbf{x})$")
ax.set_ylabel("$\mathcal{N}(0.5, \sigma(\mathbf{x})^2 \mid \hat{F}_t)$")
ax.get_legend().set_title("Var. $\sigma(\mathbf{x})^2$")
plt.savefig(os.path.join("figures", "method", "continuous_pdf.png"), dpi=600, bbox_inches="tight")
plt.close()
"""Continuous CDF figure"""
y1 = 1 - norm_dist1.cdf(x)
y2 = 1 - norm_dist2.cdf(x)
df1 = pd.DataFrame({"x": x, "y": y1, "variance": [sigma1 for _ in range(len(x))]})
df2 = pd.DataFrame({"x": x, "y": y2, "variance": [sigma2 for _ in range(len(x))]})
ax = sns.lineplot(
pd.concat([df1, df2], ignore_index=True), x="x", y="y", hue="variance", palette=["royalblue", "orange"]
)
plt.plot((mu, mu), (0.0, 1.0), color="black", linestyle="dashed")
ax.set_xlabel("$f_{th}$")
ax.set_ylabel("$p(F(\mathbf{x}) \in \mathcal{F}_{I} \mid \hat{F}_t)$")
ax.get_legend().set_title("Var. $\sigma(\mathbf{x})^2$")
plt.savefig(os.path.join("figures", "method", "continuous_cdf.png"), dpi=600, bbox_inches="tight")
plt.close()
"""Discrete PDF figure"""
classes = ["class-1", "class-2", "class-3"]
interesting_classes = [False, True, True]
probs = [0.2, 0.5, 0.3]
df = pd.DataFrame({"class": classes, "interesting": interesting_classes, "prob": probs})
ax = sns.barplot(data=df, x="class", y="prob", hue="interesting", palette=["royalblue", "orange"])
ax.set_xlabel("Class $f_I$")
ax.set_ylabel("$p(F(\mathbf{x}) = f_I \mid z_{1:t}, \mathbf{p}_{1:t})$")
ax.get_legend().set_title("Interesting $\mathcal{F}_I$")
plt.savefig(os.path.join("figures", "method", "discrete_pdf.png"), dpi=600, bbox_inches="tight")
plt.close()
"""Discrete CDF figure"""
classes = ["Uninteresting", "Interesting"]
probs = [0.2, 0.8]
df = pd.DataFrame({"class": classes, "prob": probs})
ax = sns.barplot(data=df, x="class", y="prob", hue="class", palette=["royalblue", "orange"], legend=False)
ax.set_xlabel("Binary Belief")
ax.set_ylabel("$p(F(\mathbf{x}) \in \mathcal{F}_{I} \mid \hat{F}_t)$")
plt.savefig(os.path.join("figures", "method", "discrete_cdf.png"), dpi=600, bbox_inches="tight")
plt.close()