Sub topic 11
Before/After Charts and Drilling Down
Assume you know basic percentages, cumulative sums, bar charts, and the main parts of a Pareto chart. Basic Python and pandas are needed only for the example. This chapter uses Pareto analysis as a cycle: compare the process before and after a change, then investigate the category that still contributes most to the problem.
Compare the same measure before and after
A before/after comparison tests whether an improvement changed the result. Use the same:
- Definition of the problem
- Time window length, when practical
- Population or production volume
- Category definitions
- Measurement method
Suppose a team changes a labeling step. Before the change, inspectors record 100 defects. After the change, they record 50 defects. The counts are useful, but they are not directly comparable if the team inspected 10,000 units before and only 2,000 units after.
Use a rate when the amount of opportunity changed:
\[ \text{defect rate} = \frac{\text{defects}}{\text{units inspected}} \times 100 \]
You can compare total counts, rates, cost, or another measure. State which measure you chose and why.
Use paired Pareto charts
A practical comparison places two Pareto charts side by side. Keep the category names and axis meanings consistent. Sorting each chart independently makes each chart easy to read, but it can make category positions differ. For a direct visual comparison, use one shared order, such as the before-period order.
The cumulative line answers a different question from the bars:
- Bars show the size of each category in that period.
- The line shows how much of that period's total is covered by the ranked categories.
- A category can have fewer defects after improvement but still be the largest remaining category.
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.ticker import PercentFormatter
before = pd.Series({
"Scratches": 42,
"Misalignment": 27,
"Wrong label": 11,
"Cracks": 8,
"Discoloration": 5,
"Other": 7,
})
after = pd.Series({
"Scratches": 18,
"Misalignment": 9,
"Wrong label": 8,
"Cracks": 7,
"Discoloration": 4,
"Other": 4,
})
order = before.sort_values(ascending=False).index
before = before.reindex(order)
after = after.reindex(order)
fig, axes = plt.subplots(1, 2, figsize=(12, 4), sharey=False)
for ax, values, title in zip(
axes, [before, after], ["Before improvement", "After improvement"]
):
cumulative = values.cumsum() / values.sum() * 100
ax.bar(values.index, values.values, color="C0")
ax.set_title(title)
ax.set_ylabel("Defect count")
ax.tick_params(axis="x", rotation=45)
line_axis = ax.twinx()
line_axis.plot(values.index, cumulative, color="C1", marker="o")
line_axis.set_ylim(0, 100)
line_axis.yaxis.set_major_formatter(PercentFormatter())
line_axis.axhline(80, color="gray", linestyle="--", linewidth=1)
line_axis.set_ylabel("Cumulative share")
fig.tight_layout()
plt.show()The example uses counts. If the inspection volumes differ, replace counts with rates before deciding whether the process improved.
Drill down into the leading category
Drilling down means splitting one broad category into more specific subcategories. It is useful when the top-level Pareto chart identifies a target but does not explain its cause.
For example, “Scratches” might contain:
- Scratches from incoming material
- Scratches during assembly
- Scratches during packaging
- Scratches found at final inspection
Build a second Pareto chart using only the records in the selected category. Keep the same measure and time window when comparing subcategories. This prevents a broad label from hiding several different problems.
flowchart TD
A[Top-level defect data] --> B[Create Pareto chart]
B --> C[Select largest remaining category]
C --> D[Filter records to that category]
D --> E[Group by detailed cause]
E --> F[Create drill-down Pareto chart]
F --> G[Choose a focused improvement action]
G --> H[Repeat the before/after comparison]Avoid misleading comparisons
Common errors include:
- Comparing raw counts when production volume changed.
- Changing category definitions between periods.
- Sorting the before and after charts differently without making that clear.
- Treating “Other” as a meaningful root cause. It is a signal to improve classification.
- Drilling down before checking the quality of the original data.
- Assuming the largest category is the most expensive or most dangerous.
- Counting repeated observations from the same unit as independent events.
A useful check is to calculate both the total and the normalized rate. If the count falls but the rate rises, the apparent improvement may be caused by lower volume rather than a better process.
Exercise
Exercise
Before an intervention, a process records 40 defects in 1,000 units. Afterward, it records 30 defects in 500 units. Did the defect rate improve?
Show answer
No. The rate increased from 4% to 6%, even though the raw defect count decreased.