A machine-learning pipeline that predicts imminent hard-drive failure from S.M.A.R.T. (Self-Monitoring, Analysis and Reporting Technology) telemetry. It turns a quarter of Backblaze’s real open drive data into per-drive feature windows, trains a gradient-boosting classifier to flag drives at risk, and quantifies the precision/recall trade-off a data-centre maintenance team actually faces: every false alarm is a wasted drive swap.
The failure-prediction report is live on GitHub Pages: docs/disk-failure-report.html.
smart_*_raw) that drift as a drive
degrades: reallocated sectors, pending errors, power-on hours, temperature.data/raw/ (gitignored); licence CC BY-SA 4.0.Trained on 44,993 drive-windows from a 60,000-drive sample of Q1 2024
(978 of those drives failed in the quarter; 1,251 failing windows in the
held-out test set), evaluated once on 12,954 held-out windows. Full details
in docs/metrics.json and the committed report
docs/disk-failure-report.html.
| Metric | Value |
|---|---|
| ROC-AUC (held-out) | 0.9999 |
| PR-AUC (held-out) | 0.9991 |
| Precision @ threshold | 0.994 |
| Recall @ threshold | 0.970 |
| F1 @ threshold | 0.982 |
| False-alarm rate | 0.0006 (7 of 11,703 healthy) |
days_observed (dominant),
smart_9_raw_current (power-on hours), smart_222_raw_current,
capacity_bytes, smart_192_raw_current (power-cycle count).days_observed is the dominant feature, and it partly encodes “drive
stopped reporting mid-quarter”, which is strongly correlated with failure.
This is not a label leak, but it does mean the model leans on how long a
drive has been seen. In production the same feature is the drive’s
in-service span, which is available at scoring time — so it generalizes,
but a team deploying this should re-check importance on their own fleet.python -m venv .venv && source .venv/bin/activate
pip install -e '.[dev]'
# 0. Fetch one quarter of raw telemetry (~1 GB download, ~9 GB unpacked)
bash scripts/download_data.sh
# 1. Build feature matrices (streaming; ~60k-drive sample)
diskfail prepare -c configs/example.yaml
# 2. Train, evaluate, and render the report
diskfail train -c configs/example.yaml
diskfail report -c configs/example.yaml
# 3. Score a fresh snapshot: one risk per drive.
# Use a directory of consecutive daily snapshots (the monitoring
# scenario) — a single file has too little per-drive history to score.
diskfail score -c configs/example.yaml data/raw/backblaze/data_Q1_2024 -o predictions.csv
# Tests (hermetic — synthetic drive data, no network)
python -m pytest -q
disk-failure-prediction/
├── configs/example.yaml # all knobs: data paths, split, features, model
├── data/
│ ├── raw/ # downloaded daily snapshots (gitignored)
│ └── samples/ # committed gzipped feature matrices + raw sample
├── src/diskfail/
│ ├── config.py # YAML config, validation, path resolution
│ ├── data.py # streaming ETL, fleet scan, window planning
│ ├── features.py # per-window SMART stats + trends
│ ├── model.py # gradient boosting, GroupKFold CV, evaluation
│ ├── report.py # console summary + self-contained HTML
│ └── cli.py # prepare / train / report / score
├── docs/ # committed results: metrics.json, HTML report
├── outputs/ # trained model + predictions (gitignored)
└── tests/ # hermetic tests (no network, synthetic fixtures)