3. Data preprocessing and feature engineering for equipment signals
Raw vibration, current, or acoustic signals captured from industrial equipment are rarely ready for an anomaly detection model. They carry sensor noise, DC offset, varying operating conditions, and a mixture of components that obscure the fault signature. This chapter walks through the transformation pipeline that turns a raw time series into a compact, discriminative feature vector: denoising, segmentation, and the extraction of time-domain, frequency-domain, and time-frequency features.
3.1 Denoising and Signal Conditioning
Before any feature is computed, the signal must be cleaned. Three conditioning steps are almost always applied in sequence.
DC removal and detrending. A constant offset or slow drift adds no diagnostic information but inflates time-domain statistics. Subtract the mean, or fit and remove a low-order polynomial trend when the drift is systematic (for example, a temperature-dependent baseline shift).
Bandpass filtering. Choose a passband that contains the fault-related frequencies and rejects everything else. For a bearing on a shaft rotating at fr = 25 Hz (1500 rpm), the useful band typically spans from a few hertz up to roughly 10–20 kHz, depending on the resonance frequencies excited by impacts. A Butterworth bandpass with cutoffs at 10 Hz and 15 kHz is a reasonable starting point. Always apply zero-phase filtering (filtfilt in SciPy) so that the filter does not shift the signal in time and distort impact locations.
Noise reduction. For Gaussian broadband noise, a moving-average or Savitzky–Golay filter preserves peak shape better than a simple low-pass. When the noise is impulsive rather than Gaussian, median filtering is more appropriate because it removes spikes without smearing the fault transients.
3.2 Segmentation
Continuous monitoring produces an endless stream. Models need fixed-length windows. Segmentation splits the conditioned signal into frames, and the choice of window length and overlap directly affects what the features can capture.
A practical rule: the window must contain at least several complete cycles of the lowest frequency of interest. If you care about a 20 Hz component, a 1-second window gives 20 cycles — adequate. For bearing envelope analysis where the characteristic frequency may be 100–200 Hz, a 0.1–0.5 s window is often sufficient. Overlap of 50% is common; it increases the number of training samples and smooths transitions between windows.
Segmentation should also respect operating conditions. If the machine changes load or speed, segment within each steady-state regime rather than across transitions. A window that straddles a speed change contains a smeared spectrum that belongs to neither regime.
3.3 Time-Domain Features
Time-domain features are cheap to compute and interpretable. The most useful set for equipment monitoring includes:
| Feature | Formula / Definition | What it indicates |
|---|---|---|
| RMS | √(1/N Σ xi²) | Overall energy; rises with increasing vibration |
| Peak | max |xi| | Maximum amplitude; sensitive to impacts |
| Crest factor | Peak / RMS | Impulsiveness; high for early bearing faults |
| Kurtosis | E[(x−μ)⁴] / σ⁴ | Tail heaviness; spikes when impulses appear |
| Skewness | E[(x−μ)³] / σ³ | Asymmetry; can indicate rubbing or looseness |
| Zero-crossing rate | Count of sign changes / N | Dominant frequency content in a rough sense |
Kurtosis deserves special attention. A healthy bearing produces a kurtosis near 3 (Gaussian). As a defect develops, periodic impacts create heavy tails and kurtosis rises — often to 5–10 or higher. However, kurtosis is not monotonic: once the fault becomes severe and the signal is dominated by broadband noise, kurtosis can fall back toward 3. This is why kurtosis is best used alongside other features, not as a standalone indicator.
3.4 Frequency-Domain Features: FFT
The Fast Fourier Transform converts a time window into its frequency spectrum. For a stationary signal — one whose statistical properties do not change over the window — the FFT is the natural tool. Key features extracted from the spectrum include:
- Shaft frequency and harmonics: 1×, 2×, 3× running speed. Unbalance shows up at 1×; misalignment often at 2×.
- Sidebands: peaks spaced at the shaft frequency around a carrier (e.g., gear mesh frequency). Sidebands indicate modulation, often from a local defect.
- Bearing characteristic frequencies: BPFO, BPFI, BSF, and FTF, calculated from bearing geometry and running speed. Energy at these frequencies is strong evidence of a specific bearing element fault.
- Spectral centroid and spread: scalar summaries of where the energy sits and how broadly it is distributed.
To compute a clean spectrum, apply a window function (Hann is standard) before the FFT to reduce spectral leakage, and use enough samples to get adequate frequency resolution. For a 1-second window at 25.6 kHz sampling, resolution is 1 Hz — fine enough to separate shaft harmonics but not always enough to resolve closely spaced sidebands. Zero-padding can interpolate the spectrum but does not add real resolution.
3.5 Time-Frequency Features: STFT and Wavelet
Real equipment signals are rarely stationary. Speed ramps, load changes, and transient impacts all violate the assumption behind the FFT. Time-frequency methods address this.
Short-Time Fourier Transform (STFT). Slide a window along the signal and compute an FFT for each position. The result is a spectrogram: a 2D map of frequency content versus time. The window length sets a trade-off — short windows give good time resolution but poor frequency resolution, and vice versa. For impact detection, a short window (e.g., 64–256 samples) localizes the event in time; for steady-state harmonic analysis, a longer window is better.
Wavelet transform. Instead of a fixed window, wavelets use a basis that stretches and compresses. This gives multi-resolution analysis: fine time resolution at high frequencies and fine frequency resolution at low frequencies. The discrete wavelet transform (DWT) decomposes the signal into approximation and detail coefficients across levels. For bearing fault detection, the detail coefficients at the level whose frequency band covers the bearing resonance are often the most informative. Wavelet packet decomposition goes further, splitting both low and high bands for a more uniform tiling of the time-frequency plane.
Envelope analysis. This is arguably the single most important technique for rolling-element bearing diagnosis. The bearing fault produces a low-energy, high-frequency impact that repeats at the fault frequency. The raw spectrum may show a broad resonance band but not the repetition rate. Envelope analysis extracts it:
- Bandpass the signal around the resonance band (e.g., 2–5 kHz).
- Compute the analytic signal via the Hilbert transform.
- Take the magnitude to get the envelope.
- Compute the FFT of the envelope.
The resulting envelope spectrum shows peaks at the bearing fault frequency and its harmonics, even when those frequencies are invisible in the raw spectrum. This is the standard method for early bearing defect detection.
3.6 Putting It Together: A Practical Feature Set
In practice, you do not choose one feature type. You compute a vector that spans all three domains and let the model decide what matters. A reasonable baseline for a bearing monitoring application might include:
- Time domain: RMS, peak, crest factor, kurtosis, skewness (5 features)
- Frequency domain: amplitudes at 1×–5× shaft speed, BPFO, BPFI, BSF, FTF, spectral centroid (9 features)
- Time-frequency: envelope spectrum peak at BPFO and BPFI, wavelet detail energy in 3 bands (5 features)
That is 19 features per window — manageable for most classifiers and interpretable enough for maintenance engineers to trust. Normalize each feature (z-score or min-max) using statistics from the training set only, and apply the same normalization at inference time.
The next chapter moves from feature extraction to the detection algorithms themselves, showing how these vectors are used to flag anomalies in real time.