Table of Contents
ToggleYour AI model flags a pump bearing fault, but how often is it right and how many faults does it miss? We count TP, FP, FN and TN, work out precision, recall and F1, and use them to pick a sensible alarm threshold.
A fault detection model that reports 93 % accuracy can still drown operators in false alarms. We read the four cells, calculate the metrics that matter and tune the alarm threshold for plant use.

What is a confusion matrix in AI fault detection?
Confusion matrix is the 2 by 2 table that compares what an AI fault detector predicted with what really happened in the plant. Its four cells are true positives, false positives, false negatives and true negatives, and they give precision = TP / (TP + FP) and recall = TP / (TP + FN). Example: 40 caught faults, 60 false alarms and 10 missed faults give precision 40 % and recall 80 %.
What Is a Confusion Matrix in Fault Detection?
A confusion matrix is a table that counts how many plant faults an AI model caught, how many it missed and how many false alarms it raised. Check it before you let any predictive maintenance model raise a real alarm.
- Cells: TP caught, FP false alarm, FN missed, TN normal.
- Precision = TP / (TP + FP), share of alarms that are real.
- Recall = TP / (TP + FN), share of faults that got an alarm.
- With rare faults, accuracy flatters a useless model.
The model reads data from a process historian and decides, window by window, whether a fault is present. Maintenance records tell us what really happened, and the confusion matrix puts both side by side.
The same scoring works for a bearing model, a soft sensor quality alert or an AI root cause analysis tool, and we score all of them the same way.
IBM shows how accuracy fools people: a model with one miss in 100 cases scores 99 % accuracy, yet that miss may matter most.
How to Read a Confusion Matrix?
Read a confusion matrix by matching the row (what actually happened) with the column (what the model predicted). The diagonal cells are correct decisions and the two off diagonal cells are the two kinds of mistakes.
A real fault existed and the model raised an alarm.
No fault, but the model alarmed anyway, a nuisance alarm.
A real fault existed and the model stayed quiet, the dangerous error.
Healthy equipment and no alarm, usually the biggest cell.
Some tools put the actual class in columns instead of rows, so read the axis labels first. A swapped layout silently swaps your FP and FN.
Here precision means the share of alarms that are real. That differs from instrument precision, covered in accuracy vs precision of an instrument.
How Is a Confusion Matrix Built from Plant Data?
You build a confusion matrix by splitting history into fixed time windows, letting the model predict each window and then labelling each window from maintenance records. Every window lands in exactly one of the four cells.

Our worked example in this article uses a pump bearing detector scored on 1000 one hour windows. Work orders confirm 50 fault windows and 950 normal windows, and with a threshold of 0.70 the model gives TP 40, FP 60, FN 10 and TN 890.
It does not matter whether the model is a simple rule or an anomaly detection model. Scoring only looks at what it predicted.
Label the truth before you look at model output. If the engineer sees the alarm first, labels drift towards agreeing with the model.
How to Calculate Precision and Recall from a Confusion Matrix
Precision is TP divided by all alarms, and recall is TP divided by all real faults. With our counts that gives precision 40 / 100 = 40 % and recall 40 / 50 = 80 %.
Precision = TP / (TP + FP)
= 40 / 100 = 40.0 %
Recall = TP / (TP + FN)
= 40 / 50 = 80.0 %
F1 = 2TP / (2TP + FP + FN)
= 80 / 150 = 53.3 %
Accuracy = (TP + TN) / Total
= 930 / 1000 = 93.0 %
In plant language, eight of ten bearing faults got an alarm, but six of every ten alarms sent a technician to a healthy pump. That confusion matrix result will wear out operator patience fast.

Enter your own confusion matrix counts from a site trial below. The defaults are the pump example.
Compare two models only on the same windows and labels. Our guide to Python in industrial automation shows scripts that turn historian exports into counts.
Why Is Accuracy Misleading for Imbalanced Data?
Accuracy is misleading because faults are rare, so a model that never raises an alarm still scores very high. In our example a dummy model that always says normal gets 950 / 1000 = 95 % accuracy, which beats the real model at 93 %, yet it catches zero faults.
| Metric | Formula | Pump example | What it tells the plant |
|---|---|---|---|
| Accuracy | (TP + TN) / Total | 93.0 % | Hides missed faults when faults are rare |
| Precision | TP / (TP + FP) | 40.0 % | How far operators can trust an alarm |
| Recall | TP / (TP + FN) | 80.0 % | Share of real faults that got caught |
| F1 score | 2TP / (2TP + FP + FN) | 53.3 % | One number that balances both |
| Specificity | TN / (TN + FP) | 93.7 % | Share of healthy windows left alone |
| False alarm rate | FP / (FP + TN) | 6.3 % | Nuisance load on healthy equipment |
Davis and Goadrich of the University of Wisconsin showed in their ICML 2006 paper that precision and recall give a more informative picture than ROC curves on highly skewed data. Plant fault data is exactly that, with healthy hours far outnumbering fault hours.
Imbalance also hurts training, since a model can learn to favour the normal class. Our post on vibration analysis with AI covers how fault examples are gathered.
What Is a Good F1 Score for Fault Detection?
There is no single good F1 score, because the right target depends on how costly a missed fault is compared with a false alarm. F1 is useful for comparing two models on the same data, not as a pass mark on its own.
F1 is the harmonic mean of precision and recall, so it stays low if either is low. IBM notes that some researchers criticise F1 for weighting both equally.
For a trip that shuts down a unit, a false positive is expensive, so aim for precision. For an advisory alarm on a critical compressor, a miss is worse, so lean towards recall.
- Each alarm triggers a costly action such as a shutdown
- Operators already face too many alarms per shift
- The fault develops slowly and gives several chances
- A missed fault can cause fire, injury or a long outage
- The equipment has no other protection
- A check visit is cheap compared with a failure
How to Choose the Alarm Threshold Using a Confusion Matrix
Choose the threshold by recounting the confusion matrix at a few threshold values and picking the one with the lowest total cost of misses and false alarms. Raising the threshold cuts false alarms but also misses more faults.
In our pump example, moving the threshold from 0.70 to 0.85 gave TP 35, FP 20, FN 15 and TN 930. Precision rose to 35 / 55 = 63.6 %, recall fell to 70 %, and F1 rose to 70 / 105 = 66.7 %.
Threshold 0.70: 60 FP and 10 FN
Cost = 60 × 2,000 + 10 × 5,00,000
= Rs 51,20,000
Threshold 0.85: 20 FP and 15 FN
Cost = 20 × 2,000 + 15 × 5,00,000
= Rs 75,40,000
So the higher F1 setting costs more here, because each extra miss outweighs many saved visits. Put your own costs into the confusion matrix, since the answer flips if a false alarm means a shutdown.
A time delay often beats a higher threshold. Like delay timers in ISA 18.2 alarm management, making the score stay high for two or three windows removes one off spikes.

Yokogawa summarises ISA 18.2 guidance as about 150 alarms per day being very likely acceptable and about 300 per day being the maximum manageable for an operator. A chatty AI model can eat that budget on its own.
Troubleshooting a Fault Detection Model
Most model problems show up as a pattern in the confusion matrix, so ask which cell is out of line. The table gives the usual cause and fix for each pattern.
| Symptom | Matrix sign | Likely cause | Fix |
|---|---|---|---|
| Alarms every start up | FP high in transients | Trained on steady running only | Add a running state filter |
| Faults missed at low load | FN high in one mode | Few low load fault examples | Score per operating mode |
| Precision dropped suddenly | FP jump after a date | Sensor replaced or recalibrated | Check instrument change records |
| Counts look too good | Near perfect on test | Same days in training and test | Split by date, not at random |
A slow transmitter span drift can look exactly like a developing fault to the model. Before blaming the algorithm, check calibration history for the tags feeding it.
Overfitting is the other trap, where the model memorises training days. This explainer on overfitting and underfitting shows the classic sign of a test score far above the live score.
Log every false alarm with the operator comment. After a month that log explains the FP cell better than any dashboard.
Video and Reference Paper
The StatQuest video below explains the confusion matrix with a medical example. Swap patients for pumps and the logic is identical.
For why precision and recall suit skewed data, read the Davis and Goadrich paper. It also shows why ROC and precision recall curves can rank models differently.
Checklist Before You Trust a Fault Detection Model
Go through this checklist before a model is allowed to raise alarms on a DCS or SCADA screen.
- Axis labels checked for actual and predicted
- Truth labels come from work orders, not alarms
- Test dates differ from training dates
- Precision and recall reported, not accuracy alone
- Threshold set with real plant costs
- Monthly recount has a named owner
Model alarms should follow your SCADA alarm management philosophy, with a priority and an owner. An AI alarm with no operator action belongs in a maintenance report.
For background, read our predictive vs preventive maintenance guide. Noisy signals hurt detection too, and our SNR calculator helps you check them.
Confusion Matrix FAQ
It is a table of correct and wrong predictions split into TP, FP, FN and TN. For example, a pump model with 40 caught faults, 60 false alarms, 10 misses and 890 correct normal windows fills the four cells.
Each cell is a count of windows, and all four add up to the total, which is 1000 here.
Precision is the share of alarms that were real faults, while recall is the share of real faults that got an alarm. With TP 40, FP 60 and FN 10, precision is 40 % and recall is 80 %.
So the model catches most faults but raises many false alarms.
Use F1 = 2TP / (2TP + FP + FN), which equals the harmonic mean of precision and recall. With TP 40, FP 60 and FN 10 you get 80 / 150, which is 53.3 %.
Always check that precision and recall alone also make sense for your plant.
Faults are rare, so a model that never alarms still scores high accuracy. With 50 faults in 1000 windows, an always normal model reaches 95 % accuracy and zero recall.
That is why precision, recall and F1 are the numbers to report for fault detection.
The most common mistake is reading a table with swapped axes, which swaps false positives and false negatives. Some tools put actual values in rows and others put them in columns.
Another frequent mistake is testing on the same days used for training, which makes the counts look far better than live results.
The best threshold gives the lowest total cost of missed faults plus false alarms, not simply the highest F1. Recount the four cells at a few thresholds, such as 0.70 and 0.85.
Then multiply misses and false alarms by your plant costs and pick the cheaper setting.
Related Articles
- Anomaly Detection with Machine Learning in Industry
- Predictive vs Preventive Maintenance
- Soft Sensor and Inferential Measurement
- Vibration Analysis with AI for Predictive Maintenance
- Alarm Management as per ISA 18.2
External References
- Davis and Goadrich: The Relationship Between Precision Recall and ROC Curves (PDF)
- IBM: What is a confusion matrix?
- Wikipedia: Confusion matrix
What We Learn Today
- A confusion matrix splits every scored time window into true positive, false positive, false negative or true negative, comparing model alarms with confirmed maintenance findings.
- Precision shows how far operators can trust an alarm, recall shows how many real faults get caught, and F1 balances the two in a single number.
- Choose the alarm threshold by recounting the four cells at several settings and comparing the real plant cost of missed faults against false alarm visits.

