Skip to content

Commit

Permalink
feat: Add confidence intervals to Bayesian model
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianMichelsen committed Sep 4, 2022
1 parent 04d80f0 commit 38c95d5
Showing 1 changed file with 34 additions and 9 deletions.
43 changes: 34 additions & 9 deletions src/metaDMG/viz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,26 +264,51 @@ def update_sidebar_right_datatable_results(click_data):
s1 = "Bayesian_D_max_confidence_interval_1_sigma_low"
s2 = "Bayesian_D_max_confidence_interval_1_sigma_high"
if s1 in ds and s2 in ds:
confidence_interval = [
html.Br(),
f"D-max lower bound: {ds[s1]:.3f}, upper bound {ds[s2]:.3f}",
]

s_D_max = f", [{ds[s1]:.3f}, {ds[s2]:.3f}]"

conf_q_low = ds["Bayesian_q_confidence_interval_1_sigma_low"]
conf_q_high = ds["Bayesian_q_confidence_interval_1_sigma_high"]
s_q = f", [{conf_q_low:.3f}, {conf_q_high:.3f}]"

conf_phi_low = viz_utils.human_format(
ds["Bayesian_phi_confidence_interval_1_sigma_low"]
)
conf_phi_high = viz_utils.human_format(
ds["Bayesian_phi_confidence_interval_1_sigma_high"]
)
s_phi = f", [{conf_phi_low}, {conf_phi_high}]"

conf_A_low = ds["Bayesian_A_confidence_interval_1_sigma_low"]
conf_A_high = ds["Bayesian_A_confidence_interval_1_sigma_high"]
s_A = f", [{conf_A_low:.3f}, {conf_A_high:.3f}]"

conf_c_low = ds["Bayesian_c_confidence_interval_1_sigma_low"]
conf_c_high = ds["Bayesian_c_confidence_interval_1_sigma_high"]
s_c = f", [{conf_c_low:.3f}, {conf_c_high:.3f}]"

else:
confidence_interval = []
s_D_max = ""
s_q = ""
s_phi = ""
s_c = ""

bayesian_list = [
"Fit results:",
html.Br(),
f"z: {ds['Bayesian_z']:.2f}",
html.Br(),
f"D-max: {ds['Bayesian_D_max']:.3f} "
f"± {ds['Bayesian_D_max_std']:.3f}",
*confidence_interval,
f"± {ds['Bayesian_D_max_std']:.3f}" + s_D_max,
html.Br(),
f"q: {ds['Bayesian_q']:.3f} " f"± {ds['Bayesian_q_std']:.3f}",
f"q: {ds['Bayesian_q']:.3f} " f"± {ds['Bayesian_q_std']:.3f}" + s_q,
html.Br(),
f"phi: {viz_utils.human_format(ds['Bayesian_phi'])} "
f"± {viz_utils.human_format(ds['Bayesian_phi_std'])}",
f"± {viz_utils.human_format(ds['Bayesian_phi_std'])}" + s_phi,
html.Br(),
f"A: {ds['Bayesian_A']:.3f} " f"± {ds['Bayesian_A_std']:.3f}" + s_A,
html.Br(),
f"c: {ds['Bayesian_c']:.3f} " f"± {ds['Bayesian_c_std']:.3f}" + s_c,
html.Br(),
f"rho Ac: {ds['Bayesian_rho_Ac']:.3f}",
html.Br(),
Expand Down

0 comments on commit 38c95d5

Please sign in to comment.