Hybrid CNN-LSTM deep learning model for detecting electricity theft in power distribution systems, using real consumption data from the Electricity Company of Ghana.
# AI-Based Electricity Theft Detection in Distribution Systems
A hybrid CNN-LSTM deep learning model that detects electricity theft from
customer consumption profiles in power distribution networks. Developed as a
final-year undergraduate project at the Kwame Nkrumah University of Science
and Technology (KNUST), using real consumption data from the Electricity
Company of Ghana (ECG).
## Problem
Non-technical losses from electricity theft (meter tampering, illegal
connections, bypassing) are a significant source of revenue loss for utilities.
Manual inspection is slow and costly. This project frames theft detection as a
binary classification problem on monthly consumption data, where abnormal
consumption patterns are flagged automatically for inspection.
## Approach
The pipeline has three stages:
1. **Preprocessing** (`src/preprocessing.py`) — missing and non-numeric meter
readings are mean-imputed, features are standardised, and four statistical
descriptors (interquartile range, mean, standard deviation, skewness) are
engineered per customer to summarise the shape of the yearly profile. The
combined feature set is then projected to a 2-D embedding with t-SNE, which
exposes the cluster structure separating fraudulent from normal customers.
2. **Hybrid model** (`src/hybrid_cnn_lstm.py`) — a 1-D CNN feature extractor is
wrapped in a `TimeDistributed` layer and followed by an LSTM. The CNN learns
local consumption patterns while the LSTM models how those patterns evolve,
and a sigmoid output produces the theft/normal decision.
3. **Baselines** (`src/baselines.py`) — standalone CNN, LSTM and RNN models
trained on the same features and split, used as comparison points.
## Results
On a stratified 70/30 train-test split of the ECG dataset, the hybrid
CNN-LSTM model outperformed all three baselines across every metric:
| Model | Accuracy | F1-score | Precision | Recall |
| ---------- | -------- | -------- | --------- | ------- |
| CNN-LSTM | 94.44% | 76. …