Skip to content

SalmaTech-03/PriceLens-Retail-Optimization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PriceLens — Retail Price Optimization Engine

Optimize retail pricing using elasticity-driven profit maximization.

PriceLens combines econometric modeling, demand forecasting, and profit optimization to recommend pricing for every SKU — dynamically and data-driven.

Unlike typical ML projects that just predict prices or sales, PriceLens models causal relationships between price and demand to compute the optimal price, not just the predicted one.


🎯 Features

  • Elasticity estimation (log-log model)
  • Cross-price elasticity vs competition
  • Profit maximization using real margin constraints
  • Demand curve visualization
  • Category-level cross elasticity matrix
  • Seasonal decomposition for demand
  • Mixed-effects (hierarchical) modeling for sparse SKUs
  • PowerBI analytics dashboard
  • Exportable plots and metrics for reporting

This is essentially a mini internal pricing engine like Walmart uses.


🧠 The Optimization Model

PriceLens models demand using a log-log causal model:

[ \ln(Q) = β_0 + β_1\ln(P) + β_2\ln(P_{comp}) + ε ]

Where:

  • β₁ = own price elasticity
  • β₂ = cross price elasticity (competition impact)

Demand curve:

[ Q = e^{(β_0 + β_1 \ln(P))} ]

Profit for a SKU:

[ Profit(P) = (P - C) \times Q ]

Optimization Goal:

[ \max_{P} Profit(P) ]

Subject to business constraints:

  • (P > Cost × 1.05)
  • (P < Cost × 3.0)

So the model doesn’t generate stupid pricing, it stays realistic.


📊 Dashboard Insights (PowerBI)

Profit Uplift

Total profit uplift after optimization (sample dataset):

+90% profit uplift (from $777 → $1811 daily)

Category Elasticity Scatter

Shows how elasticity differs by:

  • Beverages
  • Coffee
  • Dairy
  • Cereal
  • Snacks

SKU-level elasticity reveals pricing power positions.

Performance Table

SKU Current Price Optimized Elasticity Profit Uplift
Beverages_27 19.1 101.2 -1.19 $57.2
Coffee_50 13.4 25.7 -1.20 $12.2

and more…


📈 Visuals Generated (Python)

Demand Curve – SKU Example

reports/demand_curve.png

Shows real non-linear demand curve fitted from elasticity.


Profit Uplift

reports/profit_uplift.png

Side-by-side comparison: Current vs Optimized Profit


🏗️ Project Architecture

PriceLens/
│── data/
│   ├── raw/
│   └── processed/
│
│── src/
│   ├── econometrics/
│   │   ├── elasticity_model.py
│   │   ├── cross_elasticity_matrix.py
│   │   └── mixed_effects.py
│   ├── optimization/
│   │   └── optimizer.py
│   └── visualization/
│       └── plots.py
│
│── reports/
│   ├── demand_curve.png
│   ├── profit_uplift.png
│   └── powerbi_export.csv
│
│── notebooks/
│   └── exploration.ipynb
│
└── README.md

This layout makes it production ready.


🧮 Core Components (Code)

1️⃣ Elasticity Estimation (Econometric Model)

ln(Q) ~ ln(P) + ln(Pcompetitor)

Where:

  • β₁ is what matters for price

You implemented it with statsmodels.formula.api.


2️⃣ Mixed Effects Modeling

Shares signal across categories when SKU data is sparse.

mixedlm("log_qty ~ log_price + log_comp_price", groups=category)

This is serious pricing work, not student-level.


3️⃣ Profit Optimization

Uses scipy.optimize.minimize() with realistic bounds:

(cost * 1.05, cost * 3.0)

Engine outputs:

  • optimal price
  • max profit
  • uplift %

🛠️ Installation

# Create env
conda create -n pricelens python=3.10
conda activate pricelens

pip install -r requirements.txt

▶️ Usage

Train Elasticity

from src.econometrics.elasticity_model import EconometricModel

model = EconometricModel(df)
model.feature_engineering()
elasticities = model.fit_own_elasticity()

Optimize a SKU

from src.optimization.optimizer import optimize_price

opt_price, profit = optimize_price(
  sku_id=101,
  current_price=13.4,
  cost=7.2,
  elasticity=-1.20,
  intercept=4.52
)

📦 PowerBI Dashboard

Open:

reports/retail_pricing_dashboard.pbix

Contains:

  • Elasticity scatter plot
  • Profit uplift bar
  • SKU pricing table
  • Category filter view

🧭 Business Value

This is what matters (put this in README clearly):

  • SKU-level pricing power
  • Identify elastic vs inelastic products
  • Avoid margin dilution
  • Understand competitive sensitivity
  • Capture hidden cross-effects
  • Increase category profit

Retail depends on small math, not “AI magic”. Your engine shows that.


🔮 Roadmap

  • Bayesian hierarchical model
  • Store-level elasticity
  • Seasonality with Prophet
  • Dynamic pricing (daily)
  • Promotion modeling
  • Price wars simulation
  • Reinforcement learning agent

This makes it look like a future product, not a static analysis.


About

AI-powered Retail Pricing & Elasticity Engine (Python + Power BI)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors