Skip to content

About

Python-based pricing optimization project using retail transaction data, machine learning, and simulation to identify profit leakage and estimate a $182K margin uplift.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

19 Commits

Folders and files

Repository files navigation

Pricing Optimization & Profitability Analysis

Analyzed a ~$2.3M retail dataset (~10K orders) to identify profit leakage drivers and evaluate how discount optimization can improve margins using machine learning and simulation.

Business Problem

Despite generating strong revenue, the business is experiencing margin leakage across several product segments. High-volume categories are failing to translate sales into profit due to excessive discounting and inefficient pricing strategies.

The key challenge is to optimize discounting without negatively impacting sales performance.

This project aims to identify the drivers of profitability and quantify the impact of targeted pricing interventions using transaction-level data and machine learning.

Project Approach

1. Exploratory Data Analysis

Analyzed category and sub-category level performance to identify where margin erosion was concentrated.

Key findings:

  • Furniture generated high sales but the lowest profit margins
  • Tables, Bookcases, and Supplies were consistently loss-making
  • Discounts above ~20–25% strongly correlated with negative profitability
  • Copiers emerged as a high-profit sub-category despite lower volume

2. Predictive Modeling

To understand the drivers of profitability, I built two models:

  • Linear Regression
  • Decision Tree Regressor

The goal was to predict profit using:

  • Discount
  • Quantity
  • Category
  • Sub-Category

3. Model Results

Model R² RMSE
Linear Regression 0.073 211.96
Decision Tree 0.141 204.12

The decision tree outperformed linear regression, suggesting that profitability is influenced by nonlinear interactions between discounting, product mix and sales volume. The relatively low R² indicates that profitability is influenced by multiple interacting factors, reinforcing the need for non-linear modeling approaches.

4. Pricing Simulation

Using the trained decision tree model, a pricing intervention was simulated by capping discounts at 20%.

Estimated Impact

  • Projected profit uplift: +$182K

This highlights the significant margin improvement potential from reducing excessive discounting.

Final Recommendations

Based on the analysis and simulation results, the following actions are recommended:

1. Implement Targeted Discount Caps

Capping discounts at 20% can significantly improve profitability, particularly in high-impact sub-categories such as Binders, Machines, and Tables.

2. Shift to Segmented Pricing Strategy

A uniform discounting approach leads to margin erosion. Pricing strategies should be tailored at the sub-category level, with stricter controls on low-margin products.

3. Monitor Discount–Profit Relationship

Establish ongoing monitoring to identify when discounting negatively impacts margins and enable timely corrective actions.

4. Prioritize High-Impact Categories

A small number of sub-categories drive the majority of profit uplift. Focusing on these areas will deliver faster and more meaningful results.

5. Validate Through Experiments

Before full-scale implementation, pricing changes should be tested through controlled experiments (A/B testing) to ensure minimal impact on sales volume.

Key Insights

  • Profitability is driven by discounting, product mix, and sales volume
  • High sales do not necessarily translate into high profit
  • Discount optimization should be targeted, not uniform
  • A small number of sub-categories drive most of the potential gains

Sub-Categories Driving Most of the Simulated Profit Uplift

  • Binders: +$81.9K
  • Machines: +$29.5K
  • Tables: +$21.2K
  • Chairs: +$12.7K
  • Furnishings: +$10.8K

This indicates that even seemingly stable categories may be over-discounted and hiding margin potential.

Visualizations

Profit vs Discount

Shows the relationship between increasing discount levels and declining profitability. profit_vs_discount

Total Profit by Sub-Category

Highlights which product groups generate profit and which contribute to losses. profit_by_subcategory

Profit Uplift by Sub-Category After Discount Cap

Shows where the simulated pricing intervention generated the most value. profit_uplift_by_subcategory

Profit Distribution by Discount Bucket (optional)

Illustrates how profit distribution worsens as discount levels increase. profit_by_discount_bucket

Tools Used

  • Python
  • Pandas
  • NumPy
  • Scikit-learn
  • Matplotlib
  • Seaborn
  • Google Colab

Files in This Repository

  • pricing_analysis.ipynb — full notebook with EDA, modeling, simulation, and visualizations
  • Sample - Superstore.csv — dataset used for analysis
  • outputs/charts/ — saved visualization outputs

Business Relevance

This project demonstrates how analytics and machine learning can support pricing strategy by:

  • identifying hidden profit leakage
  • quantifying the impact of discounting
  • simulating pricing interventions
  • enabling data-driven commercial decisions

How This Would Be Implemented in a Real Business

To operationalize this analysis, the following steps can be taken:

1. Integrate with Pricing and Sales Systems

The model can be embedded into existing pricing workflows (e.g., CRM, ERP, or pricing tools) to flag transactions where discounts exceed recommended thresholds. This enables sales teams to make more informed pricing decisions in real time.

2. Build Monitoring Dashboards

Develop dashboards to track key metrics such as:

  • average discount by product segment
  • profit margin trends
  • impact of discount changes over time

This allows business teams to continuously monitor the relationship between discounting and profitability.

3. Establish Pricing Guidelines

Translate insights into clear business rules, such as:

  • maximum discount thresholds by sub-category
  • approval workflows for high-discount transactions
  • recommended discount ranges based on product margin

This ensures consistency in pricing decisions across teams.

4. Run Controlled Experiments

Before full rollout, implement A/B testing or pilot programs:

  • apply discount caps to a subset of products or regions
  • compare sales and profit outcomes against control groups

This validates the impact and reduces implementation risk.

5. Enable Sales Team Adoption

Provide training and clear communication to sales teams:

  • explain the impact of discounting on profitability
  • align incentives with margin improvement, not just revenue

Adoption is critical, even the best models fail without behavioral change.

Strategic Impact

By embedding data-driven pricing into daily operations, the business can move from reactive discounting to a more disciplined and optimized pricing strategy.

This enables sustained margin improvement, better decision-making, and scalable pricing optimization over time.

Future Improvements

Potential next steps for this analysis:

  • test additional models such as Random Forest or XGBoost
  • incorporate revenue and margin ratio features
  • simulate category-specific discount thresholds instead of a single cap
  • validate findings with controlled pricing experiments

About

Python-based pricing optimization project using retail transaction data, machine learning, and simulation to identify profit leakage and estimate a $182K margin uplift.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages