---
id: wiki-2026-0508-predictive-maintenance
title: Predictive Maintenance
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [PdM, Condition-based Maintenance, RUL Prediction]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [predictive-maintenance, anomaly-detection, iot, manufacturing, time-series]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
  language: python
  framework: pytorch, sklearn, river
---

# Predictive Maintenance

## 매 한 줄
> **"매 sensor data로 장비 failure 를 발생 전에 predict — RUL 추정 또는 anomaly detection."**. 매 reactive (고장 후) / preventive (정기점검) 대비 매 비용 30-50% 절감. 2025-2026 modern stack: edge IoT + transformer time-series (PatchTST, TimesFM) + foundation model (Chronos, MOIRAI).

## 매 핵심

### 매 두 가지 task
- **Anomaly detection**: 현재 정상/이상 binary — autoencoder, isolation forest, one-class SVM.
- **RUL (Remaining Useful Life)**: 매 남은 수명 (cycle 또는 시간) regression — LSTM, Transformer, survival.
- **Failure classification**: 매 failure mode classify — multi-class.

### 매 sensor 종류
- Vibration (accelerometer) — bearing fault key.
- Temperature, current, voltage.
- Acoustic emission.
- Oil analysis (particle count).
- Pressure, flow rate.

### 매 dataset 표준
- **NASA C-MAPSS** (turbofan engine RUL).
- **PHM 2008/2010** challenges.
- **Bosch CNC milling**.
- **CWRU bearing** (vibration).

### 매 응용
1. Manufacturing CNC, motor, pump.
2. Wind turbine gearbox.
3. Aircraft engine (NASA C-MAPSS use case).
4. Railway wheel/track.
5. Data center HVAC, server fan.
6. EV battery SoH/RUL.

## 💻 패턴

### Vibration FFT feature
```python
import numpy as np
def fft_features(signal, fs=12000):
    n = len(signal)
    fft = np.abs(np.fft.rfft(signal))[:n//2]
    freqs = np.fft.rfftfreq(n, 1/fs)[:n//2]
    return {
        'rms': np.sqrt(np.mean(signal**2)),
        'kurtosis': ((signal - signal.mean())**4).mean() / signal.std()**4,
        'peak_freq': freqs[fft.argmax()],
        'spectral_energy': fft.sum(),
    }
```

### Isolation Forest anomaly
```python
from sklearn.ensemble import IsolationForest
clf = IsolationForest(contamination=0.01, random_state=42)
clf.fit(X_normal)
scores = -clf.score_samples(X_new)  # 매 high = anomaly
```

### Autoencoder reconstruction error
```python
import torch, torch.nn as nn
class AE(nn.Module):
    def __init__(self, d, h=32):
        super().__init__()
        self.enc = nn.Sequential(nn.Linear(d, 64), nn.ReLU(), nn.Linear(64, h))
        self.dec = nn.Sequential(nn.Linear(h, 64), nn.ReLU(), nn.Linear(64, d))
    def forward(self, x):
        return self.dec(self.enc(x))

# anomaly score = reconstruction MSE — 매 정상 data로 학습 후 임계 설정
```

### LSTM RUL regression (C-MAPSS style)
```python
import torch, torch.nn as nn
class RULNet(nn.Module):
    def __init__(self, n_sensors=14, hidden=64):
        super().__init__()
        self.lstm = nn.LSTM(n_sensors, hidden, num_layers=2,
                            batch_first=True, dropout=0.2)
        self.head = nn.Sequential(nn.Linear(hidden, 32), nn.ReLU(),
                                  nn.Linear(32, 1))
    def forward(self, x):  # x: (B, T, n_sensors)
        out, _ = self.lstm(x)
        return self.head(out[:, -1]).squeeze(-1)  # RUL cycles

# loss = MSE on clipped RUL (max 125 typical)
```

### Transformer time-series (PatchTST)
```python
# pip install patchtst
from patchtst import PatchTSTForPrediction
model = PatchTSTForPrediction.from_pretrained(
    'patchtst/cmapss', context_length=96, prediction_length=1)
rul = model(sensor_window).prediction_outputs
```

### Online drift detection (river)
```python
from river.drift import ADWIN
adwin = ADWIN(delta=0.002)
for x in stream:
    adwin.update(x)
    if adwin.drift_detected:
        print('drift — retrain or alert')
```

### Survival / hazard model
```python
from lifelines import CoxPHFitter
import pandas as pd
# df: features + duration + event(0/1 failure observed)
cph = CoxPHFitter()
cph.fit(df, duration_col='cycle', event_col='failed')
hazard = cph.predict_partial_hazard(df_new)
```

### Foundation model (Chronos zero-shot)
```python
from chronos import ChronosPipeline
import torch
pipe = ChronosPipeline.from_pretrained('amazon/chronos-t5-large',
                                        device_map='cuda',
                                        torch_dtype=torch.bfloat16)
forecast = pipe.predict(context=torch.tensor(history),
                        prediction_length=24,
                        num_samples=20)  # (20, 24)
```

## 매 결정 기준
| 상황 | Approach |
|---|---|
| Labeled failure history 있음 | Supervised RUL (LSTM, PatchTST) |
| 정상 data만 있음 | Autoencoder, IsolationForest |
| Streaming sensor | Online learning + drift detect (river) |
| Few-shot / cold start | Foundation model (Chronos, MOIRAI) zero-shot |
| Survival analysis 필요 | Cox PH, DeepSurv |
| Edge / low-power | Quantized LSTM, tiny CNN |

**기본값**: anomaly = IsolationForest baseline → AE, RUL = PatchTST 또는 LSTM with clipped target.

## 🔗 Graph
- 부모: [[Time_Series]] · [[Anomaly_Detection]] · [[Industrial_AI]]
- 변형: [[Condition_Monitoring]] · [[RUL_Prediction]] · [[Failure_Classification]]
- 응용: [[Manufacturing]] · [[Aviation]] · [[Energy]] · [[Battery_Management]]
- Adjacent: [[IoT]] · [[Edge_AI]] · [[Survival_Analysis]] · [[Digital_Twin]]

## 🤖 LLM 활용
**언제**: industrial sensor pipeline 설계, anomaly detection MVP, RUL model training, foundation model TS 적용.
**언제 X**: 매 safety-critical (aviation engine)에서 매 ML model 단독 — physics-based digital twin과 ensemble.

## ❌ 안티패턴
- **Train on imbalanced labels naive**: 매 failure 1% — class weighting / focal loss / oversampling 필수.
- **Static threshold for anomaly**: drift 가 매 threshold obsolete — adaptive (ADWIN) 필요.
- **Ignore sensor lag / sync**: 매 multi-sensor fusion에서 매 timestamp align 필수.
- **No business cost model**: false alarm 비용 vs missed failure 비용 — threshold tuning에 매 반영.
- **Predict only RUL without uncertainty**: 매 quantile / probabilistic 예측 (PatchTST quantile, conformal) 필요.

## 🧪 검증 / 중복
- Verified (NASA C-MAPSS dataset, PatchTST paper, Chronos paper, sklearn IsolationForest, lifelines docs).
- 신뢰도 A.

## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — RUL + anomaly detection stack including modern foundation models |
