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.
- 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.
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.
Total profit uplift after optimization (sample dataset):
+90% profit uplift (from $777 → $1811 daily)
Shows how elasticity differs by:
- Beverages
- Coffee
- Dairy
- Cereal
- Snacks
SKU-level elasticity reveals pricing power positions.
| 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…
reports/demand_curve.pngShows real non-linear demand curve fitted from elasticity.
reports/profit_uplift.pngSide-by-side comparison: Current vs Optimized Profit
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.
ln(Q) ~ ln(P) + ln(Pcompetitor)
Where:
- β₁ is what matters for price
You implemented it with statsmodels.formula.api.
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.
Uses scipy.optimize.minimize()
with realistic bounds:
(cost * 1.05, cost * 3.0)
Engine outputs:
- optimal price
- max profit
- uplift %
# Create env
conda create -n pricelens python=3.10
conda activate pricelens
pip install -r requirements.txtfrom src.econometrics.elasticity_model import EconometricModel
model = EconometricModel(df)
model.feature_engineering()
elasticities = model.fit_own_elasticity()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
)Open:
reports/retail_pricing_dashboard.pbix
Contains:
- Elasticity scatter plot
- Profit uplift bar
- SKU pricing table
- Category filter view
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.
- 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.