Product Segmentation for Retail with Python | by Samir Saci | Towards Data Science

Product segmentation refers to the activity of grouping products that have similar characteristics and serve a similar market. It is usually related to marketing (Sales Categories) or manufacturing (Production Processes).
However, as a Logistics Manager, you rarely care about the product itself when managing goods flows; except for the dangerous and oversized products.
Your attention is mainly focused on the sales volumes distribution (fast/slow movers), demand variability and delivery lead time.
You want to put efforts into managing products that have:
The highest contribution to your total turnover: ABC Analysis
The most unstable demand: Demand Variability
In this article, we will introduce simple statistical tools to combine ABC Analysis and Demand Variability to perform products segmentation.
SUMMARYI. Scenario1. Problem Statement2. Scope Analysis3. ObjectiveII. SegmentationABC AnalysisDemand Stability: Coefficient of VariationNormality TestIII. Conclusion
You can find the full code in this Github repository: LinkMy portfolio with other projects: Samir Saci
You are the Operational Director of a local Distribution Center (DC) that delivers 10 Hypermarkets.
In your scope you the responsibility of
Preparation and delivery of replenishment orders from stores
Demand Planning and Inventory Management
This analysis will be based on the M5 Forecasting dataset of Walmart stores’ sales records (Link).
We suppose that we only have the first-year data (d_1 to d_365):
10 stores in 3 states (USA)
1,878 unique SKU
3 categories and 7 departments (sub-category)
Except for the warehouse layout, categories and departments have no impact on your ordering, picking or shipping processes.
Code — Data Processing
What does impact your logistic performance?
Products RotationWhat are the references that are driving most of your sales?
Very Fast Movers: top 5% (Class A)
The following 15% of fast movers (Class B)
The remaining 80% of very slow movers (Class C)
This classification will impact,
Warehouse Layout: Reduce Warehouse Space with the Pareto Principle using Python
www.samirsaci.com
Picking Process: Improve Warehouse Productivity using Order Batching with Python
www.samirsaci.com
Demand VariabilityHow stable is your customers’ demand?
Average Sales: μ
Standard Deviation:
Coefficient of Variation: CV = σ/μ
For SKUs with a high value of CV, you may face unstable customer demand that would lead to workload peaks, forecasting complexity and stock-outs.
Code
Filter on the first year of sales for HOBBIES Skus
Calculate Mean, Standard deviation and CV of sales
Sorting (Descending) and Cumulative sales calculation for ABC analysis
samirsaci.com
This analysis will be done for the SKU in the HOBBIES category.
What are the references that are driving most of your sales?
Class A: the top 5%- Number of SKU: 16- Turnover (%): 25%Class B: the following 15%- Number of SKU: 48 - Turnover (%): 31%Class C: the 80% slow movers- Number of SKU: 253 - Turnover (%): 43%
In this example, we cannot clearly observe the Pareto Law (20% of SKU making 80% of the turnover).
However, we still have 80% of our portfolio making less than 50% of the sales.
Code
How stable is your customers’ demand?
From the Logistics Manager's point of view, it is way more challenging to handle a peak of sales than a uniform distribution throughout the year.
In order to understand which products will bring planning and distribution challenges, we will compute the coefficient of variation of the yearly distribution of sales of each reference.
Class AFortunately, most of the A SKU have a quite stable demand; we won't be challenged by the most important SKUs.
Class BThe majority of SKUs are in the stable area; however we still spend effort on ensuring optimal planning for the few references that have a high CV.
Class CMost of the SKUs have a high value of CV;For this kind of reference a cause analysis would provide better results than a statistical approach for forecasting.
Code
Can we assume that the sales follow a normal distribution?
Most of the simple inventory management methods are based on the assumption that the demand follows a normal distribution.
Why? Because it’s easy.
Sanity CheckBefore starting to implement rules and perform forecasts it’s better to verify that this hypothesis cannot be refuted.
We’ll be using the Shapiro-Wilk test for normality; it can be implemented using the Scipy library. The null hypothesis will be (H0: the demand sales follows a normal distribution).
Bad NewsFor an alpha = 0.05, we can reject the null hypothesis for most of the SKUs. This will impact the complexity of inventory management assumptions.
Code
This operationally driven segmentation gives us a few insights on the challenges your operations will face for planning and managing the goods flows to meet your store's demand.
Have a look at my blog: https://samirsaci.com
[1] Scipy stats Shapiro Test documentation, Link