Precursors to failure Predictive maintenance
Write-up Rule explorer Machine explorer

Predicting Machine Breakdowns a Day Early¶

Simple precursor rules on the Microsoft Azure Predictive Maintenance dataset¶

Summary¶

One rule, a part's own sensor reads off and that same part logs its own error code, caught 99% of breakdowns (346 of 350) on 50 machines it never saw, about 24 hours ahead, and 9 in 10 of its alarms were real. It beat nine other hand-built rules and three machine-learning models.

Contents¶

Section What's in it
1 Introduction the problem, and how success is measured
2 Data · source and reproduction where the data comes from and what's in it
3 Method validation · scoring · the warning window · normal operation · thresholds · assumptions
4 Results the three shortlisted rules, and the one to deploy
5 What didn't work · ML models seven rejected rules and three machine-learning models
6 Impact what C09 gives a plant that it didn't have before
7 Limitations and next steps how far the numbers carry, and what I'd try next
8 Use of AI tools where a coding assistant helped, and where I corrected it
Appendix Key terms · how the project is built · what each notebook found

1 · Introduction¶

Unplanned breakdowns are expensive. When a part fails on a production line (a breakdown), the line stops, the crew scrambles for a spare part, and output is lost. If you could see a breakdown coming a day early, you could plan the repair instead of reacting to it.

This report. I searched a year of machine data for precursors, patterns that show up before a failure, and expressed each one as a simple yes/no rule checked every hour ("alarm" or "no alarm"), so an operator can understand it and trust it. Ten rules were built and tested; the best three are reported here.

Measuring success. Each rule is scored on three numbers:

  • Lift: how much more often the rule fires before failures than in normal running.
  • Precision: of the alarms it raises, how many are followed by a real failure.
  • Coverage: of the failures, how many it warned about in time.

To rank rules I fold precision and coverage into one score, F1 (0 to 1), which is high only when both are high (section 3.2).

"In time" means inside a set window of hours before the failure, early enough to act (H and W, section 3.3).

What makes it hard. Failures are rare, and sensors wobble all the time. A rule that fires constantly catches every failure, but nobody trusts it. A rule that rarely fires is usually right, but misses most failures. And when many ideas are tried, some will look good by luck, or by quietly using information from the future. The aim is to find rules that are genuinely useful, and prove it on machines they have never seen. So I split the 100 machines in half: 50 training machines to build the rules on, and 50 test machines kept aside, used only to grade them at the end. Every score on this page comes from the test machines (section 3.1).

Why this approach. Microsoft's guide treats the data as a classification problem: a model predicts which component, if any, is about to fail. I wanted something a maintenance crew could use directly: a few yes/no rules, each one sentence long, and scored honestly on machines that played no part in building them.

2 · Data¶

Where it comes from. Microsoft released this dataset as the sample data for its Predictive Maintenance Modelling Guide, a walkthrough of predicting component failures from machine telemetry, first published in the Cortana Intelligence Gallery and later in Azure AI Notebooks. It's now a popular Kaggle dataset, Microsoft Azure Predictive Maintenance, uploaded by Arnab Biswas. The data is simulated: Microsoft generated it to look like a fleet of 100 industrial machines running through 2015, so it has no gaps or missing values.

What it looks like¶

Five files, one clock. Every record carries a machine number and an hour, so all five files line up on one shared timeline: 100 machines, every hour from Jan 1, 2015 to Jan 1, 2016. Here is one real machine's year:

Machine 1, all of 2015
Sensor readings every hour · 4 sensors Error codes 5 types Maintenance a part replaced Breakdowns which part failed voltage, daily average (1 of the 4 sensors) Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Machine details: machine 1 · model 3 · 18 years old (one line per machine, never changes)

What to notice: the voltage jumps two days before machine 1's voltage part (comp1) breaks down in early March. But it also jumps twice in mid-January with no breakdown after it. Telling those two kinds of jump apart is the whole problem. (Every ✗ also has a square above it: the repair is logged as a part replaced.)

File One row means Rows Its job
Sensor readings one machine, one hour: voltage, rotation, pressure, vibration 876,100 (100 machines × 8,761 hours) clues
Error codes the machine logged an error (types error1–error5) 3,919 clues
Maintenance a part (comp1–comp4) was replaced 3,286 (starts mid-2014, so each part's age is known on day one) how long since each part was replaced
Breakdowns a part (comp1–comp4) failed 761 rows → 719 breakdowns (two parts failing in the same hour count once) what we want to warn about
Machine details the machine's model (1–4) and age (0–20 years) 100 background

In data science terms, the breakdowns are the target (what we predict) and the other files are the features (the clues). Where the data comes from and how to reproduce it: section 2.1.

2.1 · Source and reproduction¶

What it is: Microsoft's public Azure Predictive Maintenance sample, released with its Predictive Maintenance Modelling Guide: the five files shown in what the data looks like, hourly from Jan 1, 2015 to Jan 1, 2016, with no gaps or missing values.

One honest caveat: it's simulated data, and unusually tidy. Warning signs land at exactly 48 and 24 hours before a breakdown. A real factory will be messier, so the exact percentages are optimistic.

To reproduce:

  • Data: Microsoft Azure Predictive Maintenance on Kaggle, version 3, five CSVs. It downloads automatically with kagglehub.dataset_download("arnabbiswas1/microsoft-azure-predictive-maintenance"); no account needed.
  • Code: three helper files in src/. Run notebooks 01–06 in order; 01–05 each save their results to outputs/ for this notebook (appendix B). Machine split: seed 7, stratified by model.

3 · Method¶

The main choices at a glance, each explained in its own subsection below:

Choice What I picked In plain words
How rules were ranked one score, F1 high only when most breakdowns are caught and most alarms are real (3.2)
When an alarm counts (H and W) an alarm 48 to 12 hours before a breakdown (H = 12, W = 36) look back as far as the warning sign goes, and keep half a day free to act (3.3)
What "normal" means hours far from any breakdown not in the 48 h before one, not in the day after a repair, not in the first day of data (3.4)
How abnormal counts as abnormal (thresholds) 3.09 "typical wobbles" from that machine's own normal a line random noise crosses only 1 hour in 1,000 (3.5)
What counts as a breakdown any part failing; two parts failing on the same machine in the same hour count as one so one incident isn't counted twice; each part was also run on its own

3.1 · Validation: training machines and test machines¶

I built every rule on 50 training machines (the dev set), then graded it once on 50 test machines (the holdout set) that never influenced any choice: not which ideas, not their settings, not the warning window. Every score in sections 4 and 5 comes from the test machines. A few edge hours aren't graded so nothing scores by accident: the failure hour itself (it holds the repair record), the day after a repair, and the first and last days of the year.

3.2 · How rules were ranked: one score, F1¶

What F1 is. Every alarm rule is judged on two questions:

  1. Of the breakdowns, how many did it warn about? (coverage, "caught")
  2. Of its alarms, how many were real? (precision, "real")

F1 rolls the two into one score from 0 to 1. Unlike a plain average, it is pulled down toward the weaker of the two. Think of a student who has to pass two exams: scoring 98 on one and 28 on the other doesn't average out to a pass. F1 is only high when both are high.

Why it's the right yardstick here. A plant manager needs both answers to be "most": most breakdowns caught, and most alarms worth walking over for. Each of the three numbers can be gamed on its own:

  • Coverage alone rewards an alarm that's always on: it "catches" everything, but the crew soon ignores it.
  • Precision alone rewards firing only on the most obvious cases, missing most breakdowns.
  • Lift alone rewards a rule that almost never fires: one lucky alarm gives a huge lift.

F1 can't be gamed either way, so it's the one number used to rank all ten ideas and to choose the window. Lift is still checked (every kept rule clears the lift bar of 2), just not used to rank.

The chart shows three of the ideas side by side:

  • C05 catches 98% of breakdowns, but only 28% of its alarms are real. A plain average would flatter it (63%); F1 gives it 0.44.
  • C06 is right more often (64%), but misses about half the breakdowns: 0.55.
  • C09 is high on both (99% caught, 90% real): 0.94.

3.3 · When an alarm counts: the 48-hour window (H and W)¶

In plain words: each part's sensor shifts about 48 hours before it breaks, in nearly every failure on every machine, so the window looks back 48 hours. An alarm in the last 12 hours is too late to do anything, so it only counts as a catch if it comes at least 12 hours ahead (H = 12). That leaves 36 hours in which an alarm counts (W = 36).

The timeline shows the window. The chart under it is where the 48 hours comes from.

When does an alarm count as a catch?
Alarm counts as a catch (W = 36 h) Time to act (H = 12 h) sensor normal sensor reads off part's own error code Breakdown 72 h 48 h before 24 h before 12 h before 0 hours before the breakdown

How to read this chart. Each line is one part's own sensor, averaged over every time that part failed and lined up so the failure is at 0 on the right.

  • The left-to-right axis is hours before the failure: a week ago on the left, the failure on the right.
  • The up-and-down axis is how far the sensor is from that machine's normal reading. 0 means normal. One step up or down equals one "typical wobble": how much that sensor normally bounces around on a good day (a standard deviation). So +2 means the reading sits about two typical wobbles above normal, and −1.5 means it has dropped well below normal (rotation slows down as a part fails).
  • One machine or all of them? All of them. Each line averages every failure of that part across all 100 machines (for example, all 252 rotation failures, spread over 92 machines). Averaging smooths out the hourly noise, which is why the lines look so clean. But it isn't just an average effect: when I checked failures one by one, 92–98% show the same clear jump, and the typical jump starts 47–48 hours before the failure for every part.
  • Why not plain units? The four sensors measure different things (volts, rpm, pressure, vibration). Measuring each one in "typical wobbles" puts them on one scale, so they can share a chart. It's like a body temperature: 98.6°F is normal and it wobbles by about half a degree, so 99.6°F is "two wobbles up", a real fever.

Why H = 12, W = 36¶

  • W = 36 covers the whole warning sign. Each part's sensor shifts 48 hours before it fails, and its error code lands 24 hours before. A window from 48 to 12 hours before the failure contains both.
  • H = 12 leaves half a day to act. With no buffer (H = 0), an alarm one hour before a failure would count as a catch, which leaves no time to do anything. Twelve hours is about one maintenance shift: enough for the crew on duty to diagnose, get the part and repair. Reliability practice sets the warning by the time needed to respond (the net P-F interval in reliability-centred maintenance; ISO 13381-1 bases alarm limits on maintenance lead time). For a real plant, H should come from its own repair and spare-part times.

The grids below show what every other split would have scored.

Choosing the window: every option tried¶

Each square is one possible window. Down the side is H, the hours kept free to act. Across the top is W, the hours in which an alarm counts. The number in each square is the F1 score (section 3.2): darker is better. Only the outlined squares reach back exactly 48 hours, where the warning sign starts, so those are the real options. The red square is the one I chose (H = 12, W = 36).

The first grid is where the choice was made, on the 50 training machines (section 3.1 explains the split):

The second grid is the check: the same rule, held fixed, scored on the 50 test machines it never saw. Nothing was chosen here.

What the two grids show:

  • A buffer of up to 12 hours costs almost nothing. H = 0 and H = 12 are within 0.01 on both grids (0.945 vs 0.936 on training machines, 0.947 vs 0.941 on test machines). So I took the 12 hours to act.
  • Waiting until 24 hours is too close to the edge. That's exactly when the error code lands. On the test machines the score drops to 0.84.
  • Past 24 hours, everything collapses. The window closes before the error code arrives, so C09 can't fire in time.
  • The two grids agree, so a choice made on training machines carries over to machines it never saw.

3.4 · What "normal operation" means¶

Normal hours are hours far from any breakdown: not in the 48 hours before one, not in the 24 hours after a breakdown or repair (the crew is at the machine and readings reflect the restart), and not in the first 24 hours of data (the averages need a day of history). Every threshold is set from normal hours only, so no failure data leaks into it.

3.5 · How abnormal counts as abnormal (thresholds)¶

In plain words: each machine is compared with its own normal readings, like comparing your temperature with your own normal rather than everyone's. A sensor counts as "off" once it's more than 3.09 typical wobbles from that normal. Random noise crosses that line only 1 hour in 1,000.

I didn't pick 3.09 by hand. Five lines were tried, from loose to strict, and C09 did best with this one (appendix A.3). Even the strictest line can't remove the false "fevers": they're real shifts, not noise. That's why the error code is needed.

It matches long-standing factory practice. Since 1935, British quality-control charts have used an "action limit" set so chance alone crosses it only 1 time in 1,000, which is exactly 3.09 typical wobbles (source). C09's tuning landed on the same line on its own.

3.6 · Assumptions¶

  • The failure time in the log is accurate. Failures are logged once a day at 6 a.m., so I checked hour by hour that no after-the-fact data sneaks in before that time. None does.
  • The repair logged with a failure is part of the failure, not a warning sign. Otherwise "a repair was logged" would look like a perfect predictor.
  • Rules only use the past. At any hour, a rule can only look at readings from before that hour.
  • Machines never switch off (they always run), so there is no "idle" time to set aside.
  • The machines are similar enough that rules built on half of them carry over to the other half.
  • The false "fevers" are real behaviour of the machines, perhaps failures that a crew prevented. I didn't relabel them.

4 · Results: the warning signs that made the cut¶

The story in plain words. Each machine has four parts (comp1–comp4). Each part has one sensor that watches it and one error code it can log. About two days before a part breaks, its sensor moves off its normal level and stays there. About one day before, that part's own error code shows up.

The catch: sensors also move off for no reason, about 470 times a year per part, and then settle back. Think of a fever: most pass on their own. The error code is what tells you which fever is serious.

Why the error code matters¶

A drift is a sensor running a fever: clearly off that machine's normal, and staying there for at least a day. The chart counts every drift in 2015. Blue ones were followed by a failure (real); grey ones settled back on their own (look-alikes).

What the chart shows: a drift alone can't be trusted, but a drift with an error code usually can. On the sensor alone, only about 1 in 4 drifts is real. Requiring an error code throws out most look-alikes and keeps almost every real drift, so about 7 in 10 are real.

The ten ideas I tested. Seven are the obvious ones anyone would try first (C01–C07). Three combine clues, based on what the data showed (C08–C10):

ID Idea What it alarms on Result
C01 Voltage creeps up a machine's voltage rises well above its normal level (an electrical fault) rejected
C02 Rotation sags rotation speed drops well below its normal level (friction or wear) rejected
C03 Pressure builds pressure rises well above its normal level (a blockage) rejected
C04 Vibration rises vibration rises well above its normal level (bearing wear) rejected
C05 Any signal drifts any of the four sensors moves well past its normal level rejected
C06 Any error code the machine logs any error code rejected
C07 Overdue maintenance a part has gone much longer than usual since its last replacement rejected (failed a check)
C08 Drift + any error any sensor reads off and any error code was logged recently kept
C09 Matched signature a part's own sensor reads off and that same part's own error code was logged recently kept, #1
C10 Drift on an aging part a part's own sensor reads off and the part is overdue for replacement kept

Shortlisted down to three. Every idea had to pass four checks (section 5), then the top three by score were kept. Here they are, scored on the 50 test machines the rules never saw:

Warning sign In plain words Breakdowns caught Alarms that were real Warns ahead Role
1 C09 · Matched signature a part's sensor reads off and that same part logs its own error code 99% 90% ~24 h the alarm to deploy
2 C08 · Drift + any error any sensor reads off and any error code appears 91% 63% ~24 h backup, where we don't yet know which code goes with which part
3 C10 · Drift on an aging part a part's sensor reads off and the part is overdue for replacement 89% 41% ~43 h early watchlist: warns sooner, wrong more often

All three easily pass the lift test: each fires far more often before a failure than in normal running.

What the three rules look at. Every rule needs two clues at once. What separates them is whether the two clues must come from the same part. Each part has its own sensor and its own error code (comp1 voltage · error1, comp2 rotation · error2/3, comp3 pressure · error4, comp4 vibration · error5), so C09 is really four small rules, one per part, each asking "is this part's sensor off and did this part's code fire?"

Which clues each rule needs (worked example: comp3, the pressure part)
C09 · Matched signature own sensor own error code part age comp1 comp2 comp3 comp4 Both clues from the SAME part comp3's pressure off AND error4 fired 9 in 10 alarms real C08 · Drift + any error own sensor own error code part age comp1 comp2 comp3 comp4 Any sensor + any error code the clues needn't match a part 6 in 10 alarms real C10 · Drift on an aging part own sensor own error code part age comp1 comp2 comp3 comp4 Own sensor + that part's age no error code needed: earlier (~43 h) but only 4 in 10 alarms real
Out of every 100 breakdowns
C09 warned about 99. One slipped through (red ring). On the 50 test machines: 346 of 350.
Out of every 10 alarms
9 were followed by a real breakdown, 1 was a false alarm (amber ring). About 1.5 alarms per machine per month.

Recommendation: deploy C09 alone. I shortlisted three, but adding the other two barely helps. On the 50 test machines:

Added to C09 Extra breakdowns caught Extra false alarms
C08 (drift + any error) 1 462
C10 (drift on an aging part) 3 1,374

C10's one advantage is timing: it warns about 20 hours earlier. It's worth adding only if a day isn't enough to act, say a spare part that takes two days to arrive.

The exact rule definitions are in appendix A.2.

5 · What didn't work, and why¶

Each of the ten ideas from section 4 was tried with several settings (how strict the line is, how far back to look, and so on) and its best setting kept (appendix C.2). Then each idea had to pass four checks before it could compete:

  1. Not luck: it must clearly beat scrambled copies of itself (same number of alarms, shifted randomly in time). Rules built from pure random noise score about 0.08 out of 1; C09 scores 0.94.
  2. It fires more before breakdowns than in normal running, at least twice as often (lift ≥ 2).
  3. It catches a meaningful share of breakdowns, at least 5% (coverage ≥ 5%).
  4. No peeking at the future: set up on January–June only, it must still work on July–December.

Nine of the ten passed, and the top three by score were kept. Why the other seven lost:

  • Watching one sensor at a time (C01–C04): real signals, but fooled by the false "fevers". Only about 1 in 4 alarms is real.
  • Watching all four sensors at once (C05): catches 98% of breakdowns, but nearly 3 in 4 alarms are false. A crew would learn to ignore it.
  • Alarming on any error code (C06): misses about half of all breakdowns.
  • Alarming when a part is overdue for service (C07): the only idea that failed a check. It looked good only because it was quietly using information from the future; with past data alone it caught nothing (appendix C.5).

5.1 · Also rejected: a machine-learning model¶

In plain words: I also trained three machine-learning models, each given all 32 inputs the rules could use. The best one was right only 46% of the time it raised an alarm. The simple two-clue rule was both more accurate and easier to explain.

The chart below scores the models exactly like the rules: same warning window, same 50 test machines.

Why a simple rule beats a 32-input model here:

  • The warning sign is very specific: a part's own sensor reads off while its own error code is logged. C09 looks for exactly that. A general model has to work out that pairing on its own, and the simplest model can't represent it at all.
  • The models catch nearly every failure (97–100%), but raise far more false alarms. One of them also leans on "hours since maintenance", the same misleading clue that sank C07.

Fair caveat: I didn't fine-tune the models, so this is a sanity check, not the best ML could do. My rule of thumb: an alarm people can understand and trust wins unless a model clearly beats it, and none did.

6 · Impact: what C09 gives a plant that it didn't have before¶

Before this analysis, a plant with this data could wait for breakdowns, alarm on sensors that cry wolf, or replace parts on a schedule. None of them works well:

Without C09

  • Breakdowns arrive as surprises
  • Sensor alarms: about 1 in 4 real, so crews tune them out
  • Replacing parts on a schedule: no real warning (C07)
  • An alarm says "something's off", not what
  • Black-box ML: right 46% of the time

With C09

  • 99% of breakdowns flagged ahead of time (346 of 350)
  • 9 in 10 alarms real; under 2 false alarms per machine per year
  • The alarm names which part is failing
  • One sentence anyone on the floor can check

What changes on the floor:

  • About a day of warning, so repairs can be planned. C09 fires about 24 hours before a failure, and only alarms at least 12 hours ahead count. That's a full shift to diagnose, get the part and fix it during a planned stop instead of an unplanned one.
  • Alarms worth answering. On the 50 test machines, C09 raised just 85 false alarms in a year, across all 50 machines, while warning about 346 breakdowns. A crew can afford to respond to every one.
  • It points at the part. Because C09 pairs each part's own sensor with its own error code, the alarm says which part (say, comp3, pressure), so the crew brings the right spare.
  • Nothing new to install. It uses the sensors and error log the plant already has.
  • Easy to trust. "This part's sensor has been off for hours, and its own fault code just fired" is something an operator can check on screen. There's no model to maintain or explain.

What it's worth depends on the plant's cost of an hour of downtime, which this data doesn't include. Once a plant shares that, the next step is to put a dollar figure on it (section 7). And since the data is simulated, real-world numbers will be lower. What carries over is the method: find each part's own sensor and fault code, pair them, and prove it on machines the rule has never seen.

7 · Limitations and next steps¶

Limitations. The data is simulated and unusually tidy: warning signs land at exactly 48 and 24 hours before a breakdown, and machines never stop. A real plant will be messier, so treat the percentages as optimistic. What should carry over is the method: pair each part's own sensor with its own fault code, and prove the rule on machines it has never seen.

Next steps:

  • Ask the plant about the false "fevers". If a crew fixed something before it broke, some "false alarms" were really saves.
  • Score in money. Once we know what a false alarm costs versus a missed failure, rank rules by money saved.
  • Test on real data. Here the warning signs land at exactly 48 and 24 hours. A real plant's history would show how much warning there really is, and set the window from that.
  • Cut repeat alarms. C09 often fires about twice per failure. Muting it for a day after the first alarm should roughly halve the noise.
  • Push the ML further: one model per part, and re-running the training/test split many times to check the choice is stable.

8 · Use of AI tools¶

I used Claude as a coding assistant. I directed the analysis and made the key calls; it wrote most of the code to my instructions. These are the places where I caught it going wrong (full list in the README):

What the AI did What I changed
Built the test machines' thresholds from their own breakdown dates, and measured which signals matter on test machines Caught the leak. Every choice now uses training machines only
Chose H = 0, so a 1-hour warning counted as a catch Required time to act, which led to H = 12, W = 36
Set a 24-hour lead on an untested assumption Questioned it; an hour-by-hour audit showed it had no basis
Claimed the 12-hour buffer "costs ~0.01 F1", having checked only training machines Tested it on the test machines in the Rule explorer: H = 12 held up (0.941 vs 0.947), but H = 24 dropped to 0.84, so the margin matters
Explained things with jargon ("roll6", "robust", "alert lines") and confusing tables Had them rewritten in plain language

Appendix¶

The technical detail behind sections 1–8: A · key terms and exact definitions, B · how the project fits together, C · what each notebook found.

Appendix A · Key terms and exact definitions¶

A.1 · Key terms¶

Term Meaning
Event a component failure. Failures on the same machine at the same hour count as one event. "Any failure" is the main target; each part (comp1–comp4) is also run on its own.
Precursor / rule a pattern that tends to come before a failure, written as a simple yes/no rule checked every hour ("alarm" or "no alarm").
H and W for a failure at time T, the failure counts as caught if an alarm falls between T − (H + W) and T − H. Here H = 12, W = 36: an alarm between 48 and 12 hours before the failure.
Normal operation hours far from any failure: not in the 48 h before one, not in the 24 h after a failure or repair, and not in the first 24 h of data.
Lift how much more often a rule fires before failures than in normal operation (2 = twice as often).
Precision of the alarms a rule raises, the share followed by a failure within 48 hours (H + W).
Coverage of the failures, the share that had at least one alarm in their window.
F1 the single score used to pick rules: 2 × precision × coverage / (precision + coverage). It is high only when both are high, so it can't be gamed by never firing or always firing.
Training / test machines (dev / holdout) the 100 machines are split 50/50. The rules are built and tuned on the training (dev) machines and scored on the test (holdout) machines, which play no part in building them.
Drift a sensor moving away from that machine's own normal level and staying there, not just blipping. Like a person's temperature: one high reading is noise; running a fever all day is worth noticing. Each part's own sensor drifts in the two days before it fails.
Look-alike drift a drift that looks just like the ones before a failure, but no failure follows: the machine has an off day and settles back (~470 per part per year).

A.2 · The three rules, written out¶

Each rule is checked every hour on every machine, and raises an alarm when both of its conditions hold.

  • 6 h average: the mean of a sensor's last 6 hourly readings.
  • Typical wobble: how much a sensor normally bounces around on that machine (a standard deviation). Each machine is compared with its own normal (section 3.5 explains the 3.09 line).
  • Each part's own sensor and error code(s):
Part Sensor (direction of a fault) Own error code(s)
comp1 voltage (rises) error1
comp2 rotation (falls) error2 or error3
comp3 pressure (rises) error4
comp4 vibration (rises) error5

C09 · Matched signature (the alarm to act on). For any one part:

  1. its sensor's 6 h average is more than 3.09 typical wobbles away from that machine's normal, in the fault direction (on a typical machine: voltage above ~190 vs ~170 usually, rotation below ~383 vs ~449, pressure above ~113 vs ~100, vibration above ~47 vs ~40). 3.09 is the 1-in-1,000 line (section 3.5), and
  2. that part's own error code was logged at least once in the last 24 hours.

C08 · Drift + any error (the fallback):

  1. any of the four sensors' 6 h average is more than 3.72 typical wobbles away from that machine's normal, in its fault direction, and
  2. any error code was logged at least once in the last 48 hours.

C10 · Drift on an aging part (the early warning). For any one part:

  1. its sensor's 6 h average is more than 3.72 typical wobbles away from that machine's normal, in the fault direction, and
  2. the part has gone longer since its last replacement than usual: about 33 days for comp1, 31 for comp2, 34 for comp3 and 33 for comp4.

A.3 · The five sensor lines tried¶

Each idea was tried with five lines, from loose to strict (section 3.5):

How strict Typical wobbles from normal Random noise crosses it Normal hours that actually cross it Used by
loosest 1.64 1 hour in 20 6.8%
2.33 1 in 100 3.3%
2.58 1 in 200 2.8%
chosen 3.09 1 in 1,000 2.2% C09
strictest 3.72 1 in 10,000 1.7% C08, C10

How to read it. Going down, the line gets 500 times stricter for random noise, but the share of normal hours crossing it stops falling at about 2%. Those 2% aren't noise: they're the false "fevers", real shifts that no failure follows. So the sensor line alone can't be the alarm. That's the error code's job.

A.4 · Every idea at a glance¶

Each dot is one of the ten ideas at its best, on the test machines: further right catches more breakdowns, higher up raises fewer false alarms. Only C09 is high on both. Hover for details.

Appendix B · How the project fits together, and where the numbers come from¶

Two kinds of files:

  • src/ (three helper files) hold every function: data.py (settings, loading, windows), detectors.py (the rules and the ten candidates), evaluation.py (metrics, the selection protocol, audits, ML benchmark, and saving results).
  • Notebooks 01–06. Run them in order. Each of 01–05 computes its own analysis live from the raw data and, in its last cell, saves its key results to outputs/:
Run Computes Saves
01 Dataset and parameters the dataset profile, the timestamp audit, look-alike drifts, confidence outputs/01_dataset_and_parameters.json
02 Candidates the ten candidates and their variants outputs/02_candidates.json
03 ML benchmark (~2 min) three ML models, trained and scored outputs/03_ml_benchmark.json
04 Test and select (~10 min) the full selection protocol for all five event types, and the H × W grid outputs/04_test_and_select.json
05 Audit the audits of the detectors 04 kept (it reads 04's file for which ones) outputs/05_audit.json
06 Write-up (this one) nothing: it reads the five files above, plus the holdout window grid the website build saved for the Rule explorer (docs/data/rules.json) —

Why save results at all? So this write-up can summarise everything without re-running ~15 minutes of analysis, and so every number quoted here comes from the notebook that produced it. Each file records the settings it was made with (H, W, seed) and the time it ran.

Guarding against out-of-date files. The table at the top of this notebook lists each file with the time it ran. It says "re-run" if the code in src/ changed afterwards, or if notebook 04 was re-run after notebook 05 (05 audits 04's detectors), and it warns if the notebooks used different H and W settings.

When each notebook last ran, and whether its saved results are still up to date:

ran_at status
notebook
01_dataset_and_parameters 2026-11-02 04:06:47 up to date
02_candidates 2026-11-02 04:06:50 up to date
03_ml_benchmark 2026-11-02 04:08:07 up to date
04_test_and_select 2026-11-02 04:17:07 up to date
05_audit 2026-11-02 04:17:22 up to date

Appendix C · What each notebook found¶

Each subsection gives the notebook's key conclusions, then the saved numbers behind them.

C.1 · Notebook 01: dataset and parameters¶

Characteristic Finding
Events 761 failure rows → 719 events (same machine + hour merged); 131–259 per part
Sampling and gaps hourly, 100 machines × 8,761 h (Jan 1, 2015 to Jan 1, 2016; maintenance log from mid-2014); no gaps, no missing values
Clustering not a factor here: only 3 of 719 events come within a week of the previous one on the same machine, so clustering in time changes nothing in the analysis. Failures do vary by machine (0–19 each), which the confidence intervals handle by resampling whole machines
Operating regimes effectively one: the four machine models run at the same signal levels, and machines never stop
Counters vs. live readings the four sensors (volt, rotate, pressure, vibration) are live readings; the only counter is "hours since maintenance", which I build from the maintenance log
Timestamps failures are logged in a daily 06:00 batch, but an hour-by-hour check finds no post-failure data before the stamp
Where the warning signs are each part has one signature signal (comp1 → volt, comp2 → rotate, comp3 → pressure, comp4 → vibration). It shifts exactly 48 h before failure; the part's own error code lands exactly 24 h before
Key property ~470 look-alike drifts per part never end in a failure, capping a signal-only rule at 21–34% precision; the error code is in 96–100% of real drifts but only 14–18% of look-alikes
Confidence 350 scored holdout events for "any failure" (of 363; ±5 points), 65 for comp3 (±12); the data is synthetic, so treat absolute numbers as optimistic

This notebook's two key charts are in the main write-up: why the error code matters (section 4) and the 48-hour window (section 3.3).

C.2 · Notebook 02: candidate precursors¶

Where the ten ideas come from. Before a failure, the dataset offers three kinds of evidence: four live sensors, an error-code log, and a maintenance log (from which I build each part's age). I listed the ideas in two rounds. First, what each kind of evidence could show by itself (C01–C07). These are the ideas anyone would write down before looking at the data. Then, combinations suggested by what notebook 01 found in the data and what the ML models in notebook 03 leaned on (C08–C10). Keeping the obvious ideas in the race shows whether the data-driven ones really add anything (section 5).

ID Idea Why it is on the list
C01–C04 Voltage creeps up · Rotation sags · Pressure builds · Vibration rises Domain knowledge, one per sensor. Each is a classic failure mode of rotating equipment: an electrical fault disturbs the voltage, friction slows the shaft, a blockage raises pressure, bearing wear shakes the machine. They are the simplest possible precursors and the baseline the others must beat.
C05 Any signal drifts "Any failure" doesn't say which part will fail, so one alarm watches all four sensors at once.
C06 Any error code The second source of evidence. Controllers log a fault code when a part misbehaves, often before it breaks.
C07 Overdue maintenance The third source. Parts wear out with time since replacement. I included it knowing that a counter can quietly use the future, so the gate has a plausible idea to test. It fails it.
C08 Drift + any error From the data: each part's signal drifts ~470 times a year without a failure, but an error code shows up in 96–100% of real drifts and only 14–18% of look-alikes (notebook 01). From the ML models: they lean on smoothed signals and error counts (notebook 03). Both point to a drift confirmed by an error.
C09 Matched signature Notebook 01 also found that each part has its own sensor and its own error code, so C08 is sharpened to require both for the same part.
C10 Drift on an aging part A drift on a part long past its last replacement is more likely to be real. Unlike C09, it doesn't wait for the error code, so it could warn earlier.

Where "655 variants" comes from. An idea is not one rule. "Voltage creeps up" can be checked on the raw hourly reading or a smoothed one, against a fleet-wide or a per-machine usual level, at a strict or a loose cut-off. Judging an idea by its first draft could reject a good idea because of a bad setting. So each idea is built in every reasonable setting, and judged by its best version on the dev machines:

Ideas Settings tried Variants
C01–C05 (sensors) 5 ways to read the signal (hourly reading, held 3+ h, 6 h average, 24 h average, CUSUM) × 4 usual levels (fleet, machine model, machine, robust per machine) × 5 cut-offs (P95 to P99.99 of normal operation), less the 5 CUSUM + robust combinations, which don't work (CUSUM sits at 0 most of the time) 95 each, 475 in all
C06 (errors) error count over the last 24 h or 48 h × fleet or per-machine level × 5 cut-offs (P80 to P99.5) 20
C07 (part age) 4 usual levels × 5 cut-offs 20
C08 6 h or 24 h average × 2 per-machine levels × 5 sensor cut-offs × 2 error cut-offs 40
C09 6 h or 24 h average × 2 per-machine levels × 5 sensor cut-offs × error look-back of 24 h or 48 h 40
C10 6 h or 24 h average × 2 per-machine levels × 5 sensor cut-offs × 3 part-age cut-offs (P50, P75, P90) 60
All ten 655

Every cut-off comes from normal-operation hours only. Trying 655 versions also makes a lucky winner possible, which is why every idea must pass the gates (section 5) and why notebook 05 checks for luck (appendix C.5).

id title what it alerts on family variants
C01 Voltage creeps up a machine's voltage rises well above its normal level (an electrical fault) telemetry 95
C02 Rotation sags a machine's rotation speed drops well below its normal level (friction or wear) telemetry 95
C03 Pressure builds a machine's pressure rises well above its normal level (a blockage) telemetry 95
C04 Vibration rises a machine's vibration rises well above its normal level (bearing wear) telemetry 95
C05 Any signal drifts any of the four sensors moves well past its normal level combo 95
C06 Any error code the machine logs an error code, any code errors 20
C07 Overdue maintenance a part has gone much longer than usual since its last replacement counter 20
C08 Drift + any error a sensor drifts AND an error code (any code) was logged recently combo 40
C09 Matched signature a part's own sensor drifts AND that same part's own error code was logged recently combo 40
C10 Drift on an aging part a part's own sensor drifts AND that part is older than usual since its last replacement combo 60

From ideas to three rules. Part A shows where the ten ideas come from. Part B shows how they were tuned and selected by a fixed procedure that is the same for every idea. Every choice in B1–B7 uses only the dev machines. Holdout scores are recorded along the way but never used to choose anything; they are only reported at the end.

A · HOW THE TEN IDEAS CAME TO BE A1 · Common sense: one idea per kind of evidence each sensor on its own (C01–C04), all four at once (C05), any error code (C06), a part overdue for replacement (C07) A2 · What the data showed: combine them sensors often drift with no failure; an error code tells the real drifts apart (C08). Each part has its own sensor and error code (C09). Worn parts fail more, so drift + part age (C10) B · HOW THE TEN WERE TUNED AND SELECTED (NOTEBOOK 04) B1 · Ten ideas, C01–C10 each with a physical story (notebook 02) B2 · Build 655 variants every idea in every reasonable setting (table above) B3 · Set cut-offs and score on dev cut-offs from normal hours only; F1 on the 50 dev machines B4 · Keep each idea's best variant 10 tuned rules, one per idea, chosen by dev F1 B5 · Four gates (dev machines) not luck · lift ≥ 2 · coverage ≥ 5% · causal check Fails a gate C07 overdue maintenance B6 · Rank by dev F1 skip any rule that is the same alarm as a better one Outranked C01–C06: real but weaker signals B7 · Keep the top three C09 matched signature · C08 drift + any error · C10 aging part B8 · Report on holdout 50 unseen machines; their scores never chose anything

Precursor vs. variant: what is being tested¶

A precursor is what to look for. A variant is how exactly it is measured.

  • The precursor (the idea) fixes which evidence is watched (a sensor, an error code, part age, or a combination) and what pattern counts as a warning ("this sensor goes abnormally high", "a sensor drifts and that part's error code appears"). Two different precursors make different claims about what comes before a failure.
  • A variant keeps the idea fixed and turns the knobs on how it is measured:
Knob The question it answers Choices tried
Smoothing Read the raw reading, or an average? hourly reading, held 3+ h, 6 h average, 24 h average, CUSUM
Usual level "Abnormal" compared with what? the whole fleet, machines of the same model, this machine's own history (plain or robust)
Cut-off How abnormal before it counts? from the top 5% to the top 0.01% of normal running
Look-back (error codes, part age) How recent or how old must the evidence be? error codes in the last 24 h or 48 h; part age above its P50, P75 or P90

So "vibration rises, 6 h average, compared with its own machine, top 1%" and "vibration rises, raw reading, compared with the fleet, top 5%" are the same claim measured two ways, and one may simply be the better measurement.

How every variant is tested (the same for all 655): set its alert line from normal-running hours only → run it every hour of 2015 on every machine → each off-to-on switch is an alert → score it on the 50 dev machines: precision (alerts followed by a failure within 48 h), coverage (failures with an alert 48 to 12 h before) and their F1. Holdout scores are recorded but never used to choose.

Why the comparison happens in two stages:

  1. Within each idea, its variants compete on dev F1 and only the best survives. That is tuning: each idea gets its best shot, so a good idea is never rejected for a bad setting.
  2. Between ideas, only those best versions compete, through the gates and the ranking (steps B5–B7 above). Comparing variant A of one idea with variant B of another directly would be unfair, because one could lose only because it had worse settings.

C.3 · Notebook 03: ML benchmark¶

  • Three models (gradient boosting with and without the maintenance counters, and logistic regression), trained on dev machines from 32 features and scored exactly like the rules. The best, logistic regression, reaches F1 ~0.63, well below C09; section 5.1 compares them and explains why the rules win.
  • What the models lean on: smoothed signals (6 h and 24 h averages) and each part's own error counts, which pointed the candidates toward "smoothed drift + error code".
detector F1 F1 95% interval precision coverage
ML: logistic regression 0.63 [0.59, 0.66] 46% 97%
ML: gradient boosting, no maintenance counters 0.51 [0.48, 0.54] 34% 100%
ML: gradient boosting, all features 0.30 [0.26, 0.34] 18% 100%

C.4 · Notebook 04: test and select¶

  • All ten ideas were scored with lift, precision and coverage, with thresholds from normal operation only. Nine passed every gate; C07 failed the causal check. Why the others lose: section 5.
  • Kept: C09, C08 and C10 (section 4 has their scores; appendix A.2 has the rules in full).
  • Smoothing: a 6 h average works best; CUSUM is worst.
  • Choosing H and W: one F1 grid of 100 windows (heatmap in section 3.3). F1 is flat for every window that contains the error code, and collapses once H reaches 36 h.
  • Every event type: C09 ranks first for any failure and for each part separately.
event rank id rule F1 precision coverage
any 1 C09 Matched signature 0.94 90% 99%
any 2 C08 Drift + any error 0.74 63% 91%
any 3 C10 Drift on an aging part 0.56 41% 89%
comp1 1 C09 Matched signature 0.93 89% 97%
comp1 2 C10 Drift on an aging part 0.57 41% 93%
comp1 3 C01 Voltage creeps up 0.41 27% 92%
comp2 1 C09 Matched signature 0.94 90% 99%
comp2 2 C08 Drift + any error 0.78 69% 89%
comp2 3 C06 Any error code 0.23 62% 14%
comp3 1 C09 Matched signature 0.93 87% 100%
comp3 2 C10 Drift on an aging part 0.35 32% 37%
comp3 3 C03 Pressure builds 0.24 16% 52%
comp4 1 C09 Matched signature 0.99 99% 100%
comp4 2 C10 Drift on an aging part 0.61 44% 100%
comp4 3 C04 Vibration rises 0.43 27% 100%
H x W grid (dev F1): chosen H=12, W=36 -> 0.936 | H=0, W=48 -> 0.945 | best anywhere -> 0.948 | any window with H >= 36: at most 0.24

The window grid also fixed C09's settings. In each cell of grid 1 (section 3.3), C09 is re-tuned: all 40 of its variants are tried on the dev machines and the one with the best dev F1 is kept. The four settings it chooses between:

Setting Options tried Chosen (red cell)
Smoothing 6 h or 24 h average 6 h average
Usual level per-machine percentile, or robust (median + spreads) robust
Cut-off 1.64, 2.33, 2.58, 3.09 or 3.72 spreads (P95 to P99.99) 3.09 spreads (P99.9)
Error look-back 24 h or 48 h 24 h

So picking the red cell fixes everything at once: the window (H = 12, W = 36) and the rule's four settings, which together are exactly the C09 written out in appendix A.2 (dev F1 0.936 in both places). In other cells a different variant may win (for example 3.72 spreads, or a 48 h look-back); that is what lets grid 1 show each window at its best. Nothing is chosen after this step. Grid 2 only checks the result: it keeps these settings fixed and scores the rule on the holdout machines at every window.

C.5 · Notebook 05: audit (trying to break the results)¶

Notebook 05 tries to break the shortlist with the classic traps. Each passes:

  • Luck from trying many ideas. 300 rules built from pure random noise, tuned exactly like the real ones, score about 0.08 at best, against C09's 0.94 (chart below). Picking the best of many tries manufactures almost no skill.
  • Leakage through the failure hour. Scoring the failure hour itself would turn "a repair was logged" into a fake perfect rule; the failure hour is never scored.
  • Counters that leak the future. "Hours since maintenance" looks excellent until it may only use past data, then collapses; the gate rejects it (C07).
  • Time drift. Rules set up on January–June alone still work on July–December (table below).
  • Different machines. C09 works on every machine model and age band (precision 0.87–0.93, coverage 0.97–0.99).
result meaning
check
Best of 300 rules built from random noise, picked on dev machines F1 0.08 on dev, 0.08 on holdout trying many rules finds almost nothing by luck
C09: set up on Jan–Jun only, scored on Jul–Dec F1 0.93 (vs 0.93 set up on the full year) still works on months it has not seen
C08: set up on Jan–Jun only, scored on Jul–Dec F1 0.74 (vs 0.73 set up on the full year) still works on months it has not seen
C10: set up on Jan–Jun only, scored on Jul–Dec F1 0.57 (vs 0.55 set up on the full year) still works on months it has not seen