Spaces:
Runtime error
Runtime error
Commit ยท
d35ddb1
1
Parent(s): 154ddfd
Move demo to end
Browse files
app.py
CHANGED
|
@@ -13,7 +13,7 @@ eta, a, p, D, profit, var_cost, fixed_cost = sympy.symbols("eta a p D Profit var
|
|
| 13 |
np.random.seed(42)
|
| 14 |
|
| 15 |
st.set_page_config(
|
| 16 |
-
page_title="
|
| 17 |
page_icon="๐ธ",
|
| 18 |
layout="centered",
|
| 19 |
initial_sidebar_state="auto",
|
|
@@ -24,7 +24,7 @@ st.set_page_config(
|
|
| 24 |
}
|
| 25 |
)
|
| 26 |
|
| 27 |
-
st.title("
|
| 28 |
st.subheader("Setting optimal prices with Bayesian stats ๐")
|
| 29 |
|
| 30 |
# (0) Intro
|
|
@@ -102,7 +102,7 @@ curve. \nAnd you would be very right! But also very wrong as this leads us nice
|
|
| 102 |
next issue.""")
|
| 103 |
|
| 104 |
# (3) Constrained data
|
| 105 |
-
st.header("Where are we getting this data anyways?
|
| 106 |
st.markdown("""So far, we have assumed that we get (and keep getting) data on demand levels at
|
| 107 |
different price points. \n
|
| 108 |
Not only is this assumption **unrealistic**, it is also very **undesirable**""")
|
|
@@ -195,37 +195,8 @@ st.image(["assets/images/posterior_demand_sample_2.png", "assets/images/posterio
|
|
| 195 |
st.markdown("""And finally we arrive at a price point of โฌ4.04 which is eerily close to
|
| 196 |
the actual optimum of โฌ4.24""")
|
| 197 |
|
| 198 |
-
# (5)
|
| 199 |
-
st.header("
|
| 200 |
-
st.markdown("Now that we have covered the theory, you can go ahead and try it our for yourself!")
|
| 201 |
-
st.markdown("""You will notice a few things: \n
|
| 202 |
-
๐ As you increase price elasticity, the demand becomes more sensitive to price changes and thus the
|
| 203 |
-
profit-optimizing price becomes lower (& vice versa). \n
|
| 204 |
-
๐ As you decrease price elasticity, our demand observations at โฌ7.5, โฌ10 and โฌ11 become
|
| 205 |
-
increasingly larger and increasingly more variable (as their variance is a constant fraction of the
|
| 206 |
-
absolute value). This causes our demand posterior to become increasingly wider and thus Thompson
|
| 207 |
-
sampling will lead to more exploration.
|
| 208 |
-
""")
|
| 209 |
-
|
| 210 |
-
thompson_sampler = ThompsonSampler()
|
| 211 |
-
demo_button = st.checkbox(
|
| 212 |
-
label='Ready for the Demo? ๐คฏ',
|
| 213 |
-
help="Starts interactive Thompson sampling demo"
|
| 214 |
-
)
|
| 215 |
-
elasticity = st.slider(
|
| 216 |
-
"Adjust latent elasticity",
|
| 217 |
-
key="latent_elasticity",
|
| 218 |
-
min_value=0.05,
|
| 219 |
-
max_value=0.95,
|
| 220 |
-
value=0.25,
|
| 221 |
-
step=0.05,
|
| 222 |
-
)
|
| 223 |
-
while demo_button:
|
| 224 |
-
thompson_sampler.run()
|
| 225 |
-
time.sleep(1)
|
| 226 |
-
|
| 227 |
-
# (6) Extra topics
|
| 228 |
-
st.header("Some final remarks")
|
| 229 |
|
| 230 |
st.markdown("""Because we have purposefully kept the example above quite simple, you may still be
|
| 231 |
wondering what happens when added complexities show up. \n
|
|
@@ -309,4 +280,33 @@ get quite far with limited data, especially if you have an accurate prior belief
|
|
| 309 |
likely behaves.""")
|
| 310 |
st.markdown("""For reference, in our simple example where we showed a Thompson sampling update, we
|
| 311 |
were already able to gain a lot of confidence in our estimates with just 10 extra demand
|
| 312 |
-
observations.""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
np.random.seed(42)
|
| 14 |
|
| 15 |
st.set_page_config(
|
| 16 |
+
page_title="Dynamic Pricing",
|
| 17 |
page_icon="๐ธ",
|
| 18 |
layout="centered",
|
| 19 |
initial_sidebar_state="auto",
|
|
|
|
| 24 |
}
|
| 25 |
)
|
| 26 |
|
| 27 |
+
st.title("Dynamic Pricing")
|
| 28 |
st.subheader("Setting optimal prices with Bayesian stats ๐")
|
| 29 |
|
| 30 |
# (0) Intro
|
|
|
|
| 102 |
next issue.""")
|
| 103 |
|
| 104 |
# (3) Constrained data
|
| 105 |
+
st.header("Where are we getting this data anyways? ๐ฅ๏ธ")
|
| 106 |
st.markdown("""So far, we have assumed that we get (and keep getting) data on demand levels at
|
| 107 |
different price points. \n
|
| 108 |
Not only is this assumption **unrealistic**, it is also very **undesirable**""")
|
|
|
|
| 195 |
st.markdown("""And finally we arrive at a price point of โฌ4.04 which is eerily close to
|
| 196 |
the actual optimum of โฌ4.24""")
|
| 197 |
|
| 198 |
+
# (5) Extra topics
|
| 199 |
+
st.header("Some things to think about ๐ค")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
|
| 201 |
st.markdown("""Because we have purposefully kept the example above quite simple, you may still be
|
| 202 |
wondering what happens when added complexities show up. \n
|
|
|
|
| 280 |
likely behaves.""")
|
| 281 |
st.markdown("""For reference, in our simple example where we showed a Thompson sampling update, we
|
| 282 |
were already able to gain a lot of confidence in our estimates with just 10 extra demand
|
| 283 |
+
observations.""")
|
| 284 |
+
|
| 285 |
+
# (6) Thompson sampling demo
|
| 286 |
+
st.header("Demo time ๐ฎ")
|
| 287 |
+
st.markdown("Now that we have covered the theory, you can go ahead and try it our for yourself!")
|
| 288 |
+
st.markdown("""You will notice a few things: \n
|
| 289 |
+
๐ As you increase price elasticity, the demand becomes more sensitive to price changes and thus the
|
| 290 |
+
profit-optimizing price becomes lower (& vice versa). \n
|
| 291 |
+
๐ As you decrease price elasticity, our demand observations at โฌ7.5, โฌ10 and โฌ11 become
|
| 292 |
+
increasingly larger and increasingly more variable (as their variance is a constant fraction of the
|
| 293 |
+
absolute value). This causes our demand posterior to become increasingly wider and thus Thompson
|
| 294 |
+
sampling will lead to more exploration.
|
| 295 |
+
""")
|
| 296 |
+
|
| 297 |
+
thompson_sampler = ThompsonSampler()
|
| 298 |
+
demo_button = st.checkbox(
|
| 299 |
+
label='Ready for the Demo? ๐น๏ธ',
|
| 300 |
+
help="Starts interactive Thompson sampling demo"
|
| 301 |
+
)
|
| 302 |
+
elasticity = st.slider(
|
| 303 |
+
"Adjust latent elasticity",
|
| 304 |
+
key="latent_elasticity",
|
| 305 |
+
min_value=0.05,
|
| 306 |
+
max_value=0.95,
|
| 307 |
+
value=0.25,
|
| 308 |
+
step=0.05,
|
| 309 |
+
)
|
| 310 |
+
while demo_button:
|
| 311 |
+
thompson_sampler.run()
|
| 312 |
+
time.sleep(1)
|