Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -23,20 +23,21 @@ def prediction(price_max,price_step,policy_net):
|
|
23 |
1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]
|
24 |
Q_s = policy_net(to_tensor(sample_state))
|
25 |
a_opt = Q_s.max(0)[1].detach()
|
26 |
-
|
27 |
-
|
28 |
-
#plt.ylabel("Q ($)")
|
29 |
-
#t.bar_chart(price_grid, Q_s.detach().numpy(), color='crimson', width=6, alpha=0.8)
|
30 |
-
#plt.show()
|
31 |
-
return price_grid[a_opt]
|
32 |
def fun():
|
33 |
st.header("Optimal Price Action")
|
34 |
st.subheader(str(a))
|
|
|
|
|
|
|
|
|
|
|
35 |
return
|
36 |
st.header("Enter the Specification")
|
37 |
max_value = st.number_input('Enter the Maximum Value of Price',min_value=50,value = 500,step=1)
|
38 |
step = st.number_input('Enter the Price step',min_value = 10,value = 10,step=1)
|
39 |
-
a = prediction(max_value,step,pc2)
|
40 |
if st.button('Predict'):
|
41 |
fun()
|
42 |
|
|
|
23 |
1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]
|
24 |
Q_s = policy_net(to_tensor(sample_state))
|
25 |
a_opt = Q_s.max(0)[1].detach()
|
26 |
+
|
27 |
+
return price_grid[a_opt],Q_s.detach().numpy()
|
|
|
|
|
|
|
|
|
28 |
def fun():
|
29 |
st.header("Optimal Price Action")
|
30 |
st.subheader(str(a))
|
31 |
+
plt.figure(figsize=(16, 5))
|
32 |
+
plt.xlabel("Price action ($)")
|
33 |
+
plt.ylabel("Q ($)")
|
34 |
+
plt.bar_chart(price_grid, Q_s.detach().numpy(), color='crimson', width=6, alpha=0.8)
|
35 |
+
plt.show()
|
36 |
return
|
37 |
st.header("Enter the Specification")
|
38 |
max_value = st.number_input('Enter the Maximum Value of Price',min_value=50,value = 500,step=1)
|
39 |
step = st.number_input('Enter the Price step',min_value = 10,value = 10,step=1)
|
40 |
+
a,b = prediction(max_value,step,pc2)
|
41 |
if st.button('Predict'):
|
42 |
fun()
|
43 |
|