dynamic-pricing / app.py
mathiasleys's picture
Move explanation to Medium blog post
a8905e8
"""Streamlit entrypoint"""
import time
import numpy as np
import streamlit as st
from helpers.thompson_sampling import ThompsonSampler
np.random.seed(42)
st.set_page_config(
page_title="Dynamic Pricing",
page_icon="๐Ÿ’ธ",
layout="centered",
initial_sidebar_state="auto",
menu_items={
'Get help': None,
'Report a bug': None,
'About': "https://www.ml6.eu/",
}
)
st.title("Dynamic Pricing")
st.subheader("Setting optimal prices with Bayesian stats ๐Ÿ“ˆ")
st.header("Demo time ๐ŸŽฎ")
st.markdown("""In this demo you will see \n
๐Ÿ‘‰ How Bayesian demand function estimates are created based on sales data \n
๐Ÿ‘‰ How Thompson sampling will generate concrete price points from these Bayesian estimates \n
๐Ÿ‘‰ The impact of price elasticity on Bayesian demand estimation""")
st.markdown("""You will notice: \n
๐Ÿ‘‰ As you increase price elasticity, the demand becomes more sensitive to price changes and thus the
profit-optimizing price becomes lower (& vice versa). \n
๐Ÿ‘‰ As you decrease price elasticity, our demand observations at โ‚ฌ7.5, โ‚ฌ10 and โ‚ฌ11 become
increasingly larger and increasingly more variable (as their variance is a constant fraction of the
absolute value). This causes our demand posterior to become increasingly wider and thus Thompson
sampling will lead to more exploration.
""")
st.markdown("""If you are looking for more insights into how dynamic pricing is done in practice,
check out our blog post here: https://medium.com/ml6team/dynamic-pricing-in-practice-99fe2216a93d""")
thompson_sampler = ThompsonSampler()
demo_button = st.checkbox(
label='Ready for the Demo? ๐Ÿ•น๏ธ',
help="Starts interactive Thompson sampling demo"
)
elasticity = st.slider(
"Adjust latent elasticity",
key="latent_elasticity",
min_value=0.05,
max_value=0.95,
value=0.25,
step=0.05,
)
while demo_button:
thompson_sampler.run()
time.sleep(1)