Zeel commited on
Commit
b694fbc
·
1 Parent(s): fd4877b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -18,9 +18,9 @@ st.markdown(r"""
18
  """)
19
 
20
 
21
- st_col = st.columns(1)[0]
22
-
23
 
 
24
  lengthscale = st.slider('Lengthscale', min_value=0.01, max_value=1.0, value=0.25, step=0.01)
25
  variance = st.slider('Variance', min_value=0.001, max_value=0.1, value=0.025, step=0.001)
26
  noise_variance = st.slider('Noise Variance', min_value=0.001, max_value=0.01, value=0.0, step=0.001)
@@ -60,11 +60,21 @@ ax.fill_between(x_test.ravel(), pred_mean.ravel()-pred_std2.ravel(),
60
  pred_mean.ravel()+pred_std2.ravel(), alpha=0.5, label='$\\mu \\pm 2\\sigma$')
61
  ax.set_xlabel('x')
62
  ax.set_ylabel('y')
63
- ax.set_title(f"Negative Log Marginal Likelihood: {scipy.stats.multivariate_normal(np.zeros(3), k_train_with_noise).logpdf(y_train.ravel()):.4f}")
64
  ax.legend()
65
 
66
  with st_col:
67
  st.pyplot(fig)
 
 
 
 
 
 
 
 
 
 
68
 
69
  hide_streamlit_style = """
70
  <style>
 
18
  """)
19
 
20
 
21
+ st_col, st_met = st.columns([3,1])
 
22
 
23
+ old_loss = 1000.0
24
  lengthscale = st.slider('Lengthscale', min_value=0.01, max_value=1.0, value=0.25, step=0.01)
25
  variance = st.slider('Variance', min_value=0.001, max_value=0.1, value=0.025, step=0.001)
26
  noise_variance = st.slider('Noise Variance', min_value=0.001, max_value=0.01, value=0.0, step=0.001)
 
60
  pred_mean.ravel()+pred_std2.ravel(), alpha=0.5, label='$\\mu \\pm 2\\sigma$')
61
  ax.set_xlabel('x')
62
  ax.set_ylabel('y')
63
+ # ax.set_title(f"Negative Log Marginal Likelihood: {scipy.stats.multivariate_normal(np.zeros(3), k_train_with_noise).logpdf(y_train.ravel()):.4f}")
64
  ax.legend()
65
 
66
  with st_col:
67
  st.pyplot(fig)
68
+ new_loss = scipy.stats.multivariate_normal(np.zeros(3), k_train_with_noise).logpdf(y_train.ravel())
69
+ new_loss_str = f"{new_loss:.4f}"
70
+
71
+ def percentage_change():
72
+ ans = (new_loss - old_loss)/old_loss * 100
73
+ old_loss = new_loss
74
+ return f"{ans:.1f}%"
75
+
76
+ with st_met:
77
+ st.metric(label='Loss', f"{new_loss:.4f}", percentage_change())
78
 
79
  hide_streamlit_style = """
80
  <style>