Understand the three-sigma check intuitively
Measure how far each reading sits from the norm for its sensor type, and see how the statistical rule and the condition signal split the work of assigning severity.
Question for this chapter
What does a three-sigma check find, and how does an explicit condition signal change its result?
Why this matters now
Sigma is unfamiliar statistical vocabulary, but its job is simple. It converts each reading into a single number: how many standard deviations it sits from the norm for that sensor type. That puts sensors with different units on one relative scale.
Try it
Open the anomaly_detection pipeline under processed and select Run. It executes
sensor_normalization and then anomaly_detection to produce anomaly_detections.
Check the normalization result first — 216 rows become 213.
- The two
OFFLINErows are an unsupported state, so they are removed. - Five of the six missing values are carried forward from the previous reading.
- CNC-08's pressure gap runs four readings long, past the fill limit of 3, so one row cannot be kept.
Read these two rules separately in the code.
Detection rule: |value − mean for that sensor type| / stddev > sigma → anomaly
Condition rule: quality_flag starting with HIGH_ → anomaly regardless of z-score, severity HIGH
Severity: condition signal or z >= 5.0 → HIGH, z >= 4.0 → MEDIUM, otherwise → LOW
What success looks like
anomaly_detections contains six rows.
| Machine | Sensor | Value | z-score | Severity | Why it became an anomaly |
|---|---|---|---|---|---|
| CNC-03 | vibration | 4.71 | 6.89 | HIGH | condition signal + statistics |
| CNC-05 | pressure | 8.9 | 4.92 | HIGH | condition signal + statistics |
| CNC-09 | temperature | 103.7 | 4.60 | HIGH | condition signal + statistics |
| CNC-07 | temperature | 101.2 | 4.22 | HIGH | condition signal + statistics |
| CNC-01 | temperature | 99.8 | 4.00 | MEDIUM | statistics only |
| CNC-02 | vibration | 2.75 | 3.27 | LOW | statistics only |

Find where the two rules diverge
Put CNC-01 and CNC-07 side by side. Both are temperature sensors and their z-scores are nearly
identical at 4.00 and 4.22. Yet their severities split into MEDIUM and HIGH.
The difference is not the z-score — it is quality_flag. CNC-07's source row carries HIGH_TEMP
while CNC-01's is OK. A condition signal pins severity to HIGH even when the z-score falls short
of 5.0.
Change the threshold and confirm
Change sigma_multiplier in the anomaly_detection code and rerun.
sigma_multiplier | Anomalies | Row that drops out |
|---|---|---|
| 3.0 (default) | 6 | — |
| 3.3 | 5 | CNC-02 LOW (z 3.27) |
| 4.1 | 4 | CNC-01 MEDIUM (z 4.00) |
Even at 4.1 the four HIGH rows remain, because rows carrying a condition signal are preserved
independently of the statistical rule. Restore 3.0 after the experiment.
Next decision
You have separated the six anomalies by origin. In the next chapter, compress them into machine-level
scores and choose the first inspection among the four HIGH machines.