akashananddd commited on
Commit
62db0a3
·
verified ·
1 Parent(s): e7b16dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -0
app.py CHANGED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ import matplotlib.pyplot as plt
4
+
5
+ # App title
6
+ st.set_page_config(page_title="Dynamic Pricing AI", layout="centered")
7
+ st.title("💸 AI-Based Dynamic Pricing System")
8
+ st.write("""
9
+ This web app calculates *dynamic product prices* based on demand, supply, competition, and seasonal factors — just like real businesses do.
10
+ """)
11
+
12
+ # Sidebar Inputs
13
+ st.sidebar.header("Input Parameters")
14
+ base_price = st.sidebar.number_input("Base Product Price (₹)", min_value=50.0, value=100.0)
15
+ demand = st.sidebar.slider("Demand Level", 0.0, 1.0, 0.5)
16
+ supply = st.sidebar.slider("Supply Level", 0.0, 1.0, 0.5)
17
+ competition_price = st.sidebar.number_input("Competitor Average Price (₹)", min_value=50.0, value=100.0)
18
+ season_factor = st.sidebar.slider("Season Factor (Festive = 1.2, Off-season = 0.8)", 0.5, 1.5, 1.0)
19
+
20
+ # Dynamic Pricing Formula
21
+ dynamic_price = base_price * (1 + (demand - supply) * 0.4) * season_factor
22
+ dynamic_price = (dynamic_price + competition_price) / 2
23
+
24
+ # Show recommended price
25
+ st.subheader(f"💡 Recommended Dynamic Price: ₹{round(dynamic_price, 2)}")
26
+
27
+ # Visualization: Price vs Demand Curve
28
+ demand_values = np.linspace(0, 1, 10)
29
+ prices = base_price * (1 + (demand_values - supply) * 0.4) * season_factor
30
+ prices = (prices + competition_price) / 2
31
+
32
+ plt.figure(figsize=(6,4))
33
+ plt.plot(demand_values, prices, marker='o', color='blue', label='Price vs Demand')
34
+ plt.xlabel('Demand Level')
35
+ plt.ylabel('Price (₹)')
36
+ plt.title('Dynamic Pricing Curve')
37
+ plt.legend()
38
+ plt.grid(True)
39
+ st.pyplot(plt)
40
+
41
+ # Explanation
42
+ st.write("""
43
+ ### 📈 How it Works
44
+ - *Higher demand* → price increases
45
+ - *Higher supply* → price decreases
46
+ - *Season factor* adjusts prices for festive/off-season
47
+ - *Competitor price* ensures market competitiveness
48
+
49
+ ### 🎓 Business Concepts
50
+ - Demand-Supply Economics
51
+ - Price Elasticity
52
+ - Strategic Pricing
53
+ - AI & Data-Driven Decision Making
54
+ """)
55
+
56
+ st.info("💬 Try adjusting sliders to see how the recommended price changes in real-time!")