Quickstart¶
This walks the whole load → spec → analysis flow on a small worked dataset, with
the actual printed output so you know what to expect.
1. Load a frame and attach metadata¶
mfgQC analyses consume a QCData object. You build one by load-ing a tidy
DataFrame and naming the measurement column, then attaching spec limits fluently:
import numpy as np, pandas as pd, mfgqc
rng = np.random.default_rng(7)
df = pd.DataFrame({
"width": np.round(rng.normal(1.52, 0.12, size=100), 3),
"lot": np.repeat(np.arange(1, 21), 5), # 20 subgroups of 5
})
qc = (mfgqc.load(df, measure="width", subgroup="lot", subgroup_size=5)
.spec(lower=1.0, upper=2.0, target=1.5))
measure= names the value column; subgroup= names the column that groups
measurements into rational subgroups; .spec(...) attaches the engineering
tolerances. Everything is immutable — each call returns a new object.
2. Capability¶
Process Capability (method=normal)
==================================
n = 100 mean = 1.4992
sigma (within) = 0.1105
sigma (overall) = 0.10556
Cp/Cpk sigma = within (R-bar/d2)
Cp = 1.508 95% CI (1.3, 1.72)
Cpk = 1.506 95% CI (1.29, 1.73) (Cpu=1.51, Cpl=1.506)
Pp = 1.579 Ppk = 1.576 (Ppu=1.581, Ppl=1.576)
Cpm = 1.579
Assumption checks:
[PASS] normality (Anderson-Darling): AD=0.301, p=0.572; est. Cpk impact 5.0%; n=100
[FAIL] subgroup_sufficiency (subgroup count >= 25): subgroup count 20; n=20
Recommendations:
- Only 20 subgroups; >=25 recommended for a stable within-sigma estimate.
Notice three things that make this more than a Cpk calculator:
- Both σ families are reported — within-subgroup (Cp/Cpk) and overall
(Pp/Ppk) — with the estimator named (
R-bar/d2). See Capability. - Confidence intervals are shown because small-sample point estimates are overconfident.
- The assumptions are checked and reported. Here normality passes but the subgroup count is flagged as low — mfgQC tells you, and recommends a fix, but does not silently change the calculation. See Reading the assumption report.
3. Control chart¶
With no kind=, mfgQC infers the right chart from the subgroup size (here 5 → X̄-R):
Control Chart: xbar_r (inferred); rules=nelson
==============================================
Xbar: CL=1.4992 UCL=1.6475 LCL=1.3509
R: CL=0.25705 UCL=0.5434 LCL=0
Out-of-control signals: none (process in control)
Assumption checks:
[PASS] independence (lag-1 autocorrelation): r=0.193, p=0.387; n=20 [low power]
See Choosing a control chart for the inference rule and how to override it.
4. Every result has the same surface¶
cap = qc.capability()
cap.report() # the full text above
cap.summary() # {'Cp': 1.508, 'Cpk': 1.506, 'Pp': 1.579, ...}
cap.to_dict() # full JSON payload (fields + assumptions + provenance)
cap.view(save="cap.png") # the canonical capability histogram + spec/limit overlay
Consume to_dict() / summary() from code — never parse report() text.
Next steps¶
- Reading the assumption report — what the guardrails mean.
- Gage R&R workflow — measurement-system analysis end to end.
- The audit workflow — record and verify a result's lineage.