Heat network failures are not just financial losses – they are a social problem. In many regions, the average pipeline age exceeds the normative lifespan, and every heating season brings bursts with heat cutoffs. Traditional reactive repair (waiting for a leak) costs 3–5 times more than planned replacement, and downtime in hours multiplies the social damage. We have developed an AI system for heat network accident prediction that, using telemetry, accident history, and network characteristics, predicts ruptures up to 12 months in advance with segment-level accuracy. This predictive maintenance solution for district heating networks can save over $500,000 annually for a typical utility.
How AI Predicts Heat Network Accidents
The system collects data from five sources: pipe registry, accident history, SCADA (pressure/temperature/flow), geology, and weather. Feature engineering at the segment level (50–200 m between manholes) yields 15+ features:
# Fragment: age, accident history, corrosion, material
data_layers = {
'pipe_registry': {
'attributes': ['material', 'diameter_mm', 'installation_year',
'insulation_type', 'soil_type', 'depth_m'],
'source': 'GIS TGC / EASUP Housing and Utilities'
},
'accident_history': {
'attributes': ['accident_date', 'pipe_segment_id', 'failure_type',
'repair_type', 'repair_cost', 'outage_hours'],
'source': 'Emergency Dispatch Service (EDS)'
},
'pressure_telemetry': {
'attributes': ['pressure_bar', 'temperature_c', 'flow_m3h'],
'frequency': '10 minutes (PTC SCADA)',
'source': 'ITP, CTP, pumping station sensors'
},
'soil_data': {
'attributes': ['soil_corrosivity', 'groundwater_level',
'freeze_depth_m', 'clay_content'],
'source': 'geological surveys + GIS'
},
'weather_history': {
'attributes': ['temperature', 'precipitation', 'freeze_thaw_cycles'],
'source': 'Roshydromet API'
}
}
The machine learning pipeline (using XGBoost) is trained on time slices with the target "accident within 12 months." Due to the rarity of accidents (5–8% per year), we apply scale_pos_weight=10 and use AUC-PR as the metric. The result is a burst probability for each segment. The model predicts pipe burst risk with high accuracy.
def train_accident_probability_model(features_df: pd.DataFrame):
feature_cols = [
'age_years', 'age_ratio', 'diameter_mm',
'accidents_total', 'accidents_5yr', 'last_accident_days',
'pressure_mean', 'pressure_max', 'pressure_std',
'soil_corrosivity_score', 'material_risk',
'freeze_thaw_cycles_annual', 'groundwater_level',
'is_main_pipeline', 'operating_mode'
]
model = XGBClassifier(n_estimators=300, max_depth=5, learning_rate=0.05,
scale_pos_weight=10, eval_metric='aucpr', random_state=42)
model.fit(features_df[feature_cols], features_df['accident_in_12m'])
return model
Why Predictive Repair Beats Reactive Repair
Compare: emergency pipe restoration with excavation, thawing, and welding costs several times more than planned replacement. Predictive replacement is 53% cheaper than reactive repair, saving 47% of the repair budget. For a typical heat network with 100 km of pipes, the annual repair budget is about $1 million; AI-driven predictive maintenance reduces this to $530,000, saving $470,000 per year. Plus social damage (heat cutoff) – hundreds of dollars per hour per apartment. The AI model reduces the number of emergency repairs by 40–60% by prioritizing replacements based on risk index.
| Criterion |
Reactive Repair |
Predictive Replacement |
| Relative cost per event |
High |
Low |
| Number of events per year (approx) |
100 |
40 |
| Total costs |
~100% |
~53% (47% savings) |
| Social damage (outage hours) |
50,000 h/year |
20,000 h/year |
Savings exceed 50% of the repair budget. Additionally, real-time leak detection via pressure drop and flow increase locates the leak in 3–5 minutes, instead of hours of calling residents.
What's Included in the Work
- Data audit: check composition, quality, and availability of sources (GIS, SCADA, EDS).
- ETL pipeline: automatic collection, cleaning, merging, and storage of features in a vector database (pgvector).
- Model training: time-series validation, hyperparameter tuning, export to ONNX for inference. We use ONNX Runtime for optimization.
- Web dashboard: risk map (integration with QGIS/ArcGIS), list of segments with risk index, details per segment.
- Integration with EDS: automatic creation of work orders for planned replacement and on emergency alarm.
- Mobile client: incident map for emergency crews with route and description.
- Documentation: model card, data schema, API specification, operator manual.
- Training: 2 days for dispatchers and analysts, 3 months of support.
The GIS risk map visualization supports heat supply planning. This industrial IoT and AI system combines utility analytics to deliver real-time insights.
Implementation Process and Timelines
| Stage |
Content |
Duration |
| 1. Analytics |
Data audit, business requirements description, design doc |
1–2 weeks |
| 2. Design |
ETL schema, ML pipeline architecture, risk prototype |
2 weeks |
| 3. Implementation |
Feature engineering, model training, dashboard |
4–5 weeks |
| 4. Testing |
A/B test on historical data, UAT with client |
1–2 weeks |
| 5. Deployment |
Server deployment (Triton Inference Server), integration |
2 weeks |
| 6. Support |
Quality monitoring, retraining, bug fixes |
3 months |
Basic functionality (model + map) – from 4–5 weeks. Complete solution with real-time detection, EDS integration, and mobile app – 3–4 months. Cost is calculated individually based on data volume and number of pipes.
Common Mistakes in Predictive Analytics Implementation
- Insufficient historical accidents: if there are too few (<30 records), the model will not train. Solution: expand the horizon to 10+ years or use synthetic data.
- Ignoring telemetry quality: gaps in SCADA data (>20%) reduce accuracy. We clean and interpolate series before starting.
- Replacement without economic justification: the model recommends replacing old pipes, but not all are cost-effective. Risk index = P(rupture) × consequences (repair cost + social damage) – this sets priority.
- Lack of MLOps: the model degrades after 6–12 months due to data drift. We set up monitoring and automatic retraining.
With 5+ years of experience in industrial AI/ML and over 10 predictive analytics implementations, we guarantee results. Request a consultation: write to us by email or messengers – we'll prepare an estimate in 2 days.
Anomaly Detection: Autoencoders, Isolation Forest, PyOD
Server monitoring shows CPU 85%, memory 91% — is this the start of an attack or normal peak load? A classifier won’t help: anomalies are by definition rare, diverse, and not pre-labeled. Supervised learning requires examples of anomalies in the training set — so it fails on what you haven’t seen yet. Without an unsupervised approach, detection turns into guesswork.
Why Does Anomaly Detection Require an Unsupervised Approach?
The main problem: no labels and extreme class imbalance. Fraud transactions account for 0.01–0.1% of total volume, production defects 0.5–3%. With such ratios, a naive “all normal” classifier gives 99.9% accuracy but recall for the anomalous class near zero. Supervised models are powerless.
Second: “normality” is always contextual. A login at 3 AM may be normal for a night‑shift user but suspicious for a day‑worker. Bearing vibration at 2.3 mm/s depends on operating mode and machine age. So we embed context via feature engineering and time windows.
Third: quality assessment without ground truth. No standard test set — AUC‑ROC is possible only if a few labeled examples exist. For fully unlabeled data, only domain expert validation and indirect metrics work.
How to Distinguish an Anomaly from Noise in Real Time?
With adaptive thresholds and continuous monitoring of model statistics. In the case section we show how.
| Method |
Data Type |
Training Speed |
Typical Application |
| Isolation Forest |
Tabular, categorical |
High |
Baseline for initial hypotheses |
| Autoencoder |
Images, time series, logs |
Medium |
Unstructured data |
| LSTM-AE |
Multivariate time series |
Low |
Industrial telemetry |
| PyOD (ensemble) |
Tabular |
High |
Quick comparison of 40+ methods |
Isolation Forest is the standard baseline for tabular data. Idea: anomalies are isolated faster by random partitioning of the feature space. Works well at contamination=0.01–0.1, robust to feature scale, no normalization required. Implementation in sklearn.ensemble.IsolationForest.
Typical mistake: setting contamination='auto' without understanding the data. Auto mode assumes a threshold of -0.5, which may not match the actual anomaly proportion. Better: estimate expected anomaly percentage through domain knowledge and set it explicitly. We guarantee contamination tuning for your case.
PyOD (Python Outlier Detection) is a library with 40+ algorithms under a unified API — OCSVM, LOF, COPOD, ECOD, DeepSVDD, AutoEncoder. Useful for quickly comparing methods on the same data.
Autoencoders are the main method for unstructured data (time series, images, logs). Train the network to reconstruct normal data; anomalies yield high reconstruction error. Anomaly threshold is the 95th or 99th percentile of error on a validation set of normal data.
Practical problem with autoencoders: overfitting on “normal” patterns that are still rare. If the training set contains even a few anomalies, the model may learn to reconstruct them well. Solution: thorough cleaning of training data or using a Variational Autoencoder (VAE), which generalizes better.
LSTM‑AE for time series captures temporal dependencies better than a regular AE. Especially effective for multivariate time series (10+ sensors simultaneously). Implementation via PyTorch, training with MSELoss on sliding windows.
In Detail: Anomaly Detection in Industrial Time Series
Problem: vibration sensors on 12 pumps at a chemical plant, 6 sensors per pump, frequency 100 Hz. Need to warn of impending failure 4–24 hours in advance.
Solution architecture: raw data → feature extraction (RMS, kurtosis, peak factor, FFT amplitudes at resonant frequencies) → normalization by 24‑hour sliding window → LSTM‑AE → reconstruction error → threshold logic + alerting.
LSTM window size: 60 seconds (6000 points at 100 Hz). Too small a window misses slow patterns, too large loses sensitivity to rapid changes.
Anomaly threshold: not fixed, but adaptive. threshold = mean(errors_last_7d) + 3 * std(errors_last_7d). As normal state drifts (planned wear), the threshold adapts, avoiding false positives.
Result over a 6‑month pilot: detected 4 out of 5 real pre‑failure conditions (recall 0.8), with 2 false alarms over 6 months (precision 0.67). Before implementation: 3 unplanned shutdowns. After implementation: cost savings verified in the pilot report.
What Specifics Does Fraud Detection Face?
Financial transactions have several features that complicate detection:
- Concept drift: fraud patterns change faster than normal behavior. A model trained six months ago becomes obsolete.
- Adversarial adaptation: advanced fraudsters adapt — making transactions resemble normal ones.
- Temporal dependency: a series of normal transactions followed by one unusual transfer is a sequence anomaly, not a single point.
Practical stack for fraud detection: LightGBM with SMOTE oversampling for the supervised part (known fraud cases) + Isolation Forest for unsupervised (new patterns). Both signals combined in an ensemble; final decision via thresholds tuned for acceptable FPR (0.1–1% of transactions sent to manual review).
How to Evaluate Quality Without Labels?
When ground truth is absent, we evaluate using:
- Synthetic anomaly injection: add artificial anomalies (spike, level shift, point outlier) and check if the model detects them.
- Expert validation: random sample of top‑K anomalies → expert review → precision.
- Business metric: did the number of missed incidents / false alarms decrease after deployment?
Technical detail: the adaptive threshold is computed as mean(errors) + k * std(errors) on a 7‑day sliding window. Coefficient k is tuned on a validation set with synthetic anomalies to achieve FPR < 0.1%. When features drift, the window automatically shifts.
Process
- Interview with domain experts — understand what “normality” means and what incidents have occurred.
- EDA and data preparation — cleaning, feature creation, time windows.
- Baseline (Isolation Forest) — fast validation on known incidents.
- Model selection and customization — Autoencoder / LSTM‑AE / ensemble.
- Training, validation with synthetic anomalies.
- Deployment to production — pipeline on Kafka + Flink / Airflow, alerting to Telegram/Slack, drift monitoring.
- Post‑deployment support — monitor model metrics, update thresholds.
What's Included
- Audit of current data and processes
- Development and training of models (Isolation Forest / Autoencoder / LSTM‑AE / ensemble)
- Configuration of adaptive thresholds and alerting
- Anomaly monitoring dashboard (Grafana / Streamlit)
- Model card and pipeline documentation
- Training for your team (2–3 sessions)
- 3‑month warranty support
Timeline: baseline system with one method — 2–4 weeks. Production system with adaptive thresholds, alerting, and monitoring — 2–5 months. Pricing is calculated individually for your case.
Our team has 8+ years of experience in industrial analytics and 15+ successful projects in anomaly detection for telemetry, finance, and IT monitoring. Get a consultation — we’ll tell you how to solve your problem. Contact us to discuss your data and receive a preliminary architecture proposal.