Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -23,8 +23,13 @@ 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 |
-
return price_grid[a_opt],Q_s.detach().numpy()
|
28 |
def fun():
|
29 |
st.header("Optimal Price Action")
|
30 |
st.subheader(str(a))
|
@@ -33,14 +38,11 @@ def fun():
|
|
33 |
st.header("Enter the Specification")
|
34 |
max_value = st.number_input('Enter the Maximum Value of Price',min_value=50,value = 500,step=1)
|
35 |
step = st.number_input('Enter the Price step',min_value = 10,value = 10,step=1)
|
36 |
-
a
|
37 |
if st.button('Predict'):
|
38 |
fun()
|
39 |
-
|
40 |
-
|
41 |
-
columns=["a", "b"])
|
42 |
-
|
43 |
-
st.bar_chart(chart_data)
|
44 |
|
45 |
|
46 |
|
|
|
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 |
+
plt.figure(figsize=(16, 5))
|
27 |
+
plt.xlabel("Price action ($)")
|
28 |
+
plt.ylabel("Q ($)")
|
29 |
+
plt.bar(price_grid, Q_s.detach().numpy(), color='crimson', width=6, alpha=0.8)
|
30 |
+
plt.savefig('price.png')
|
31 |
+
return price_grid[a_opt]
|
32 |
|
|
|
33 |
def fun():
|
34 |
st.header("Optimal Price Action")
|
35 |
st.subheader(str(a))
|
|
|
38 |
st.header("Enter the Specification")
|
39 |
max_value = st.number_input('Enter the Maximum Value of Price',min_value=50,value = 500,step=1)
|
40 |
step = st.number_input('Enter the Price step',min_value = 10,value = 10,step=1)
|
41 |
+
a = prediction(max_value,step,pc2)
|
42 |
if st.button('Predict'):
|
43 |
fun()
|
44 |
+
image = Image.open('price.png')
|
45 |
+
st.image(image,caption = 'Price Optimization',width =1000)
|
|
|
|
|
|
|
46 |
|
47 |
|
48 |
|