Classification asks "which of these known faults is it?". Anomaly detection asks a different and often more practical question: does this unit sound like a normal one? It is trained on normal samples only, so you can put it to work on a line where defects are rare, where nobody can list the failure modes in advance, or where the faults you will meet next month have not happened yet.
| Situation | Classification | Anomaly detection |
|---|---|---|
| Fault types are known and can be labelled | Preferred | Possible, but gives less information |
| Defective samples are very rare | Hard — too few examples to learn from | Preferred |
| Unknown or new failure modes must be caught | Misses anything not in the training set | Preferred — flags anything unlike normal |
| You need to name the fault, not just detect it | Preferred | Only reports "abnormal" |
An autoencoder is a network trained to compress a sound into a small internal representation and rebuild it again. Trained exclusively on normal recordings, it becomes very good at rebuilding normal sounds and stays clumsy at everything else. The mismatch between input and rebuild — the reconstruction error — is therefore small for normal units and large for abnormal ones.
Because normal units are not all identical, their errors form a distribution rather than a single number. The threshold is placed on the upper tail of that distribution: everything to the right of it is reported as an anomaly.
Go to Step 2 — Train Model, choose Python (deep learning) and press
Export Autoencoder Template. Point the script at a folder of normal recordings, set the output
.onnx path and the number of epochs (100 is a reasonable starting point for an autoencoder), and
start the run.
data\
Normal\
unit_0001.wav
unit_0002.wav
unit_0003.wav
...
Each recording is converted into a Mel spectrogram (64 Mel bands × 128 frames) which the network learns to reproduce. Because there is only one class, no labelling work is needed at all — collecting known-good units is the entire data preparation.
At the end of training the script measures the reconstruction error of every training sample and derives a
threshold as mean + 3 × standard deviation. This is written next to the model as a small
JSON file with the same name plus .meta.json:
{
"threshold": 0.004120,
"mean_error": 0.001850,
"std_error": 0.000757,
"n_samples": 240
}
When the model is loaded, this file is picked up automatically, so the detector arrives already calibrated to your line. Keep the two files together when you copy a model to another machine. The threshold can be adjusted afterwards to trade the two kinds of mistake against each other:
| Adjustment | Effect | Choose when |
|---|---|---|
| Lower threshold (e.g. mean + 2σ) | Catches more defects, raises false alarms | An escaped defect is expensive; re-checking is cheap |
| Default (mean + 3σ) | Balanced starting point | First deployment, before real data is available |
| Higher threshold (e.g. mean + 4σ) | Fewer false alarms, more escapes | Operators are ignoring alarms because there are too many |
Each analysed sample returns:
Normal or ANOMALYThe z-score is the number to trend. A unit at z = 3.1 has barely crossed the line and is worth a listen; a unit at z = 15 is grossly different from anything seen in training. Plotting the z-score of every unit produced during a shift often reveals drift long before individual units start failing.
A second, lighter-weight detector is available as a normal analysis in the Insert catalogue: AI Anomaly Score. It needs no neural network and no training run. Instead it computes a 14-dimensional feature vector per frame — eight time-domain descriptors (RMS, kurtosis, crest, shape, impulse and margin factors, energy entropy, zero-crossing rate) and six spectral ones (centroid, spread, flatness, crest, entropy, roll-off) — and measures how far each frame deviates from a baseline in units of standard deviation.
The scale is intuitive: a frame that matches the baseline exactly scores 0, and a frame that sits one standard deviation away in every feature scores exactly 1. The result is a score curve over time, with alarms where the threshold is exceeded, so you see when in the recording the abnormality occurs — not just whether it is present.
The baseline can come from three places, in order of precedence:
| Baseline source | Meaning | Use for |
|---|---|---|
| Baseline statistics file | A saved baseline previously fitted on known-good units | Production screening against a fixed reference |
| First N seconds of the recording | The start of the file defines "normal" | Run-in monitoring, degradation during a test |
| Whole file (default) | The recording is its own reference | Finding the relatively most unusual passage in one recording |
A fitted baseline can be exported to a JSON file and re-loaded later, which is how you keep a whole test bench — or several benches — judging against the same reference. Frames are analysed with a 2048-point window, 1024-sample hop and a Hann window by default; the reported single value is the 95th percentile of the score curve, so a short transient does not dominate the summary.
© 2026 Deepsona. All Rights Reserved.