import streamlit as st import numpy as np import matplotlib.pyplot as plt # App title st.set_page_config(page_title="Dynamic Pricing AI", layout="centered") st.title("💸 AI-Based Dynamic Pricing System") st.write(""" This web app calculates *dynamic product prices* based on demand, supply, competition, and seasonal factors — just like real businesses do. """) # Sidebar Inputs st.sidebar.header("Input Parameters") base_price = st.sidebar.number_input("Base Product Price (₹)", min_value=50.0, value=100.0) demand = st.sidebar.slider("Demand Level", 0.0, 1.0, 0.5) supply = st.sidebar.slider("Supply Level", 0.0, 1.0, 0.5) competition_price = st.sidebar.number_input("Competitor Average Price (₹)", min_value=50.0, value=100.0) season_factor = st.sidebar.slider("Season Factor (Festive = 1.2, Off-season = 0.8)", 0.5, 1.5, 1.0) # Dynamic Pricing Formula dynamic_price = base_price * (1 + (demand - supply) * 0.4) * season_factor dynamic_price = (dynamic_price + competition_price) / 2 # Show recommended price st.subheader(f"💡 Recommended Dynamic Price: ₹{round(dynamic_price, 2)}") # Visualization: Price vs Demand Curve demand_values = np.linspace(0, 1, 10) prices = base_price * (1 + (demand_values - supply) * 0.4) * season_factor prices = (prices + competition_price) / 2 plt.figure(figsize=(6,4)) plt.plot(demand_values, prices, marker='o', color='blue', label='Price vs Demand') plt.xlabel('Demand Level') plt.ylabel('Price (₹)') plt.title('Dynamic Pricing Curve') plt.legend() plt.grid(True) st.pyplot(plt) # Explanation st.write(""" ### 📈 How it Works - *Higher demand* → price increases - *Higher supply* → price decreases - *Season factor* adjusts prices for festive/off-season - *Competitor price* ensures market competitiveness ### 🎓 Business Concepts - Demand-Supply Economics - Price Elasticity - Strategic Pricing - AI & Data-Driven Decision Making """) st.info("💬 Try adjusting sliders to see how the recommended price changes in real-time!")