Lean Six Sigma with Python — Kruskal Wallis Test | by Samir Saci | Towards Data Science

Lean Six Sigma (LSS) is a method based on a stepwise approach to process improvements.
This approach usually follows 5 steps (Define, Measure, Analyze, Improve and Control) for improving existing process problems with unknown causes.
In this article, we will explore how Python can replace Minitab (Software widely used by LSS experts) in the Analysis step to test hypotheses and understand what could improve the performance metrics of a specific process.
SUMMARYI. Problem StatementCan we improve the operators' productivity by giving them a training designed by R&D team?II. Data Analysis1. Exploratory Data AnalysisAnalysis with Python sample data from experiment with few operators 2. Analysis of Variance (ANOVA)Verify the hypothesis that training impacts productivityANOVA assumptions are not verified3. Kruskal-Wallis testConfirm that the hypothesis can be generalizedIII. Conclusion
You are the Continous Improvement Manager of a Distribution Center (DC) for an iconic Luxury Maison focusing on Fashion, Fragrances and Watches.
The warehouse receives garments that require final assembling and value-added service (VAS) during the inbound process.
For each dress received your operators need to print a label in the local language and perform label sewing.
In this article, we will focus on the improvement of label sewing productivity. Labels are distributed to the operators by batches of 30 labels. The productivity is calculated based on the time (in seconds) needed to finish a batch.
Edit: You can find a Youtube version of this article with animations in the link below.
With the support of the R&D team, you designed training for the VAS operators to improve their productivity and reduce quality issues.
QuestionDoes the training have a positive impact on the productivity of operators?
HypothesisThe training has a positive impact on the productivity of VAS operators.
ExperimentRandomly select operators and measure the time per batch (Time to finish a batch of 30 labels in seconds) to build a sample of 56 records.
You can find the full code in this Github repository: LinkMy portfolio with other projects: Samir Saci
You can download the results of this experiment in this CSV file to run the whole code on your computer (here).
56 records35 records of operators without training21 records of operators with training
Box Plot
Based on the sample data, we can see that the median and the mean of the is considerably lower for the operators who had training.
HypothesisThe training reduces the average time per batch.
Code
MinitabMenu Graph > Box Plot > Simple > 1 Y with Groups 
In this scenario, we want to check if the training (Variable X) is impacting the total time per batch (Variable Y).
Because X is a categorical variable (Training = Yes/No) and Y is numerical, the appropriate method is ANOVA.
ANOVA is a statistical method used to check if we can generalize the difference of means seen in the sample data to the entire population.
Step 1: Calculate the p-value
Source: Trainingddof:   11ddof:   245.267F:      17.1066p-unc:  0.000151308p:      20.173692p-value is below 5%
Code
MinitabMenu Stats > ANOVA > One-Way 
Step 2: Validate the assumptions of ANOVA
Based on the p-value, we know that the difference of mean is real and not due to random fluctuation.
However, before jumping to a conclusion we need to check that the ANOVA assumptions are satisfied
Residuals are naturally distributed
Answer: No
There are no outliers or irregularities
Answer: No
ConclusionANOVA requirements are not met, we need another method to confirm that the training actually impacts operators productivity.
Code
MinitabMenu Stats > ANOVA > One-Way > Graphs > Four in one
If your sample data fails to meet ANOVA requirements, you can use Kruskal-Wallis Test to check if the difference of means is due to random fluctuation.
statistic = 54.99pvalue = 1.205e-13p-value is below 5%
ConclusionThe p-value is below 5% so we can conclude that the difference of means is statically significant.
We can confirm that the training has a positive impact on the productivity of the operators.
Code
MinitabMenu Stats > Non-parametric > Kruskal Wallis > Graphs > Four in one
If you are interested in other applications of Lean Six Sigma Methodology using Python you can have a look at the articles below:
www.samirsaci.com
www.samirsaci.com
This data-driven approach gave you enough elements to convince your management to invest in workforce training.
You brought enough insights with a moderate effort of experimentation by generalising patterns from sample data using statistics.
Please feel free to contact me, I am willing to share and exchange on topics related to Data Science and Supply Chain.My Portfolio: https://samirsaci.com
[1] ANOVA Analysis of Variation, Ted Hessing, Six Sigma Study Guide, link[2] Scheduling of Luxury Goods Final Assembly Lines with Python, Samir Saci, link